Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

ipfs.files.get and ipfs.files.cat do not support ipfs-path format #837

Closed
kyledrake opened this issue Apr 24, 2017 · 5 comments
Closed

ipfs.files.get and ipfs.files.cat do not support ipfs-path format #837

kyledrake opened this issue Apr 24, 2017 · 5 comments
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue

Comments

@kyledrake
Copy link

let ipfsPath = 'QmcKi2ae3uGb1kBg1yBpsuwoVqfmcByNdMiZ2pukxyLWD8/index.html'
ipfs.files.cat(ipfsPath, (err, stream) => {
  console.log('throws exception before it gets to this')
})

The go-ipfs daemon takes care of this for me (ipfs cat QmcKi2ae3uGb1kBg1yBpsuwoVqfmcByNdMiZ2pukxyLWD8/index.html), so I was surprised to run into this.
The way it seems to be implemented in js-ipfs is that ipfs.files.get can iterate over every "file" and provides an object with a path and stream, but that could have performance implications if we were trying to grab individual objects from larger trees. I don't always want to go through the whole thing.

@dryajov
Copy link
Member

dryajov commented Apr 24, 2017

I believe that your hash has to be "fully qualified" with /ipfs/QmHash/index.html

@kyledrake
Copy link
Author

Nope, even with that I still get this for ipfs.files.get: Error: not valid multihash. ipfs.files.cat throws an exception for a non-base58 character.

@daviddias
Copy link
Member

@kyledrake is correct, currently we don't support subpaths, also tracked here #60

@kyledrake would you like to help us achieve that? This would require a modification to the https://github.com/ipfs/js-ipfs-unixfs-engine, it needs to discard part of the tree traversal operations.

@daviddias daviddias added exp/expert Having worked on the specific codebase is important enhancement help wanted Seeking public contribution on this issue labels May 7, 2017
@daviddias
Copy link
Member

Hi @kyledrake, apologies for the wait here, this took way longer than I would hope for, it was one low hanging fruit item that we left open to welcome contributions, shouldn't have left it open for so long.

Now it is done on master, it will come with next release of ipfs or you can use it by git cloning and npm link yourself :)

@daviddias
Copy link
Member

Also, this comes with tests and documentation, see: https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#cat :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue
Projects
None yet
Development

No branches or pull requests

3 participants