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

Commit 819bb38

Browse files
fix: add support for protobuf in object.put
1 parent 388264c commit 819bb38

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/api/object.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,24 @@ module.exports = (send) => {
6868
}
6969
const enc = options.enc || 'json'
7070

71-
send('object/put', enc, null, buf, (err, result) => {
71+
send('object/put', null, {inputenc: enc}, buf, (err, result) => {
7272
if (err) {
7373
return callback(err)
7474
}
7575

7676
if (Buffer.isBuffer(obj)) {
7777
if (!options.enc) {
7878
obj = { Data: obj, Links: [] }
79-
} else {
79+
} else if (options.enc === 'json') {
8080
obj = JSON.parse(obj.toString())
8181
}
8282
}
8383
let node
8484
if (obj.multihash) {
8585
node = obj
86+
} else if (options.enc === 'protobuf') {
87+
node = new DAGNode()
88+
node.unMarshal(obj)
8689
} else {
8790
node = new DAGNode(obj.Data, obj.Links)
8891
}

0 commit comments

Comments
 (0)