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

Commit a3efca9

Browse files
committed
files.cat
1 parent 0af4371 commit a3efca9

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/files/cat.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const promisify = require('promisify-es6')
44
const cleanCID = require('../utils/clean-cid')
55
const v = require('is-ipfs')
6+
const bl = require('bl')
67

78
module.exports = (send) => {
89
return promisify((hash, opts, callback) => {
@@ -19,10 +20,14 @@ module.exports = (send) => {
1920
}
2021
}
2122

22-
send({
23-
path: 'cat',
24-
args: hash,
25-
buffer: opts.buffer
26-
}, callback)
23+
send({ path: 'cat', args: hash, buffer: opts.buffer }, (err, stream) => {
24+
if (err) { return callback(err) }
25+
26+
stream.pipe(bl((err, data) => {
27+
if (err) { return callback(err) }
28+
29+
callback(null, data)
30+
}))
31+
})
2732
})
2833
}

0 commit comments

Comments
 (0)