Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
fix: add support for protobuf in object.put
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed May 13, 2016
1 parent 388264c commit 819bb38
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/api/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,24 @@ 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)
}

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)
}
Expand Down

0 comments on commit 819bb38

Please sign in to comment.