Commit f9307a44 authored by project's avatar project

--no commit message

--no commit message
parent 6825976a
...@@ -19,7 +19,11 @@ module.exports.parse = function(obj) ...@@ -19,7 +19,11 @@ module.exports.parse = function(obj)
var jsonobj = BSON.parse(obj); var jsonobj = BSON.parse(obj);
return new BSData(jsonobj.data,jsonobj.data_type); return new BSData(jsonobj.data,jsonobj.data_type);
}else if(obj.data_type && obj.data){ }else if(obj.data_type && obj.data){
return new BSData(obj.data,obj.data_type); var oData = obj.data;
if(obj.encoding == 'base64'){
oData = new Buffer(obj.data,'base64');
}
return new BSData(oData,obj.data_type);
}else{ }else{
return null; return null;
} }
...@@ -78,6 +82,9 @@ BSData.prototype.serialize = function(type){ ...@@ -78,6 +82,9 @@ BSData.prototype.serialize = function(type){
bsdata.encoding = 'base64'; bsdata.encoding = 'base64';
} }
if(type=='object-encoded'){
return bsdata;
}
return JSON.stringify(bsdata); return JSON.stringify(bsdata);
} }
......
...@@ -37,7 +37,7 @@ Db.prototype.request = function(req,cb) ...@@ -37,7 +37,7 @@ Db.prototype.request = function(req,cb)
Db.prototype.bsscmd_w = function(cmd,cb) Db.prototype.bsscmd_w = function(cmd,cb)
{ {
var self = this; var self = this;
var filepath = this.repos_dir + '/' + name2path(cmd.storage) + '.bss' var filepath = this.repos_dir + '/' + name2path(cmd.storage) + '.bss';
var bssname = cmd.storage; var bssname = cmd.storage;
var w_cmd = { var w_cmd = {
'command' : 'write', 'command' : 'write',
......
function resource(cfg)
{
cfg = cfg || {};
this.resource_store = cfg.resource_store;
}
resource.prototype.getData = function(res,cb)
{
if(res.type == 'data')
{
cb(null,res.value);
}else if(res.type == 'ref'){
cb(null,"");
}else{
cb("unsupported datatype");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment