diff --git a/SPEC/FILES.md b/SPEC/FILES.md index f63f9c8d..2220ecd1 100644 --- a/SPEC/FILES.md +++ b/SPEC/FILES.md @@ -166,6 +166,7 @@ pull( ipfsPath can be of type: - [`cid`][cid] of type: + - a [CID](https://github.com/ipfs/js-cid) instance - [Buffer][b], the raw Buffer of the cid - String, the base58 encoded version of the cid - String, including the ipfs handler, a cid and a path to traverse to, ie: @@ -202,6 +203,7 @@ A great source of [examples][] can be found in the tests for this API. ipfsPath can be of type: - [`cid`][cid] of type: + - a [CID](https://github.com/ipfs/js-cid) instance - [Buffer][b], the raw Buffer of the cid - String, the base58 encoded version of the cid - String, including the ipfs handler, a cid and a path to traverse to, ie: diff --git a/js/src/files.js b/js/src/files.js index ff68065b..033372ba 100644 --- a/js/src/files.js +++ b/js/src/files.js @@ -18,6 +18,7 @@ const through = require('through2') const path = require('path') const bl = require('bl') const isNode = require('detect-node') +const CID = require('cids') module.exports = (common) => { describe('.files', function () { @@ -375,6 +376,16 @@ module.exports = (common) => { }) }) + it('with a cid object', (done) => { + const cid = new CID(smallFile.cid) + + ipfs.files.cat(cid, (err, data) => { + expect(err).to.not.exist() + expect(data.toString()).to.contain('Plz add me!') + done() + }) + }) + it('streams a large file', (done) => { ipfs.files.cat(bigFile.cid, (err, data) => { expect(err).to.not.exist()