From aac2d8238686485a51704471a05125cfe1671f20 Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Wed, 21 Mar 2018 22:15:14 +0100 Subject: [PATCH 1/3] docs: add files.cat with cid instance to spec License: MIT Signed-off-by: Jacob Heun --- SPEC/FILES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/SPEC/FILES.md b/SPEC/FILES.md index f63f9c8d..99d5791b 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: From c86cbefe57c0fe7f8310cc45ae9c57ea06eba43e Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Wed, 21 Mar 2018 22:31:35 +0100 Subject: [PATCH 2/3] docs: add files.catReadableStream with cid instance to spec License: MIT Signed-off-by: Jacob Heun --- SPEC/FILES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/SPEC/FILES.md b/SPEC/FILES.md index 99d5791b..2220ecd1 100644 --- a/SPEC/FILES.md +++ b/SPEC/FILES.md @@ -203,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: From 04505c3437622f5a50e6c24c67ef38e30f977990 Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Wed, 21 Mar 2018 22:32:34 +0100 Subject: [PATCH 3/3] test: add failing test for file.cat with cid instance License: MIT Signed-off-by: Jacob Heun --- js/src/files.js | 11 +++++++++++ 1 file changed, 11 insertions(+) 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()