From 819bb38adf9f6c650586ee310a8da17865151322 Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Fri, 13 May 2016 22:50:46 +0200 Subject: [PATCH] fix: add support for protobuf in object.put --- src/api/object.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/api/object.js b/src/api/object.js index 29cf38408..8e5689835 100644 --- a/src/api/object.js +++ b/src/api/object.js @@ -68,7 +68,7 @@ module.exports = (send) => { } const enc = options.enc || 'json' - send('object/put', enc, null, buf, (err, result) => { + send('object/put', null, {inputenc: enc}, buf, (err, result) => { if (err) { return callback(err) } @@ -76,13 +76,16 @@ module.exports = (send) => { if (Buffer.isBuffer(obj)) { if (!options.enc) { obj = { Data: obj, Links: [] } - } else { + } else if (options.enc === 'json') { obj = JSON.parse(obj.toString()) } } let node if (obj.multihash) { node = obj + } else if (options.enc === 'protobuf') { + node = new DAGNode() + node.unMarshal(obj) } else { node = new DAGNode(obj.Data, obj.Links) }