Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

Passing a pull-stream to ipfs.add is interpreted as a callback #25

Closed
olizilla opened this issue Apr 19, 2018 · 3 comments
Closed

Passing a pull-stream to ipfs.add is interpreted as a callback #25

olizilla opened this issue Apr 19, 2018 · 3 comments
Labels
kind/bug A bug in existing code (including security flaws)

Comments

@olizilla
Copy link

If you pass a pull-stream to ipfs.add like:

const pullStream = fileReader(file)
const ipfsRef = await ipfs.files.add(pullStream)

It's interpreted as a callback fn and callbackify is invoked, which causes an error in callbackifyVariadic

Type error: cb is not a function

Passing it as part of an array of entires avoids that issue, but then hits a known issue later on

const pullStream = fileReader(file)
const ipfsRef = await ipfs.files.add([{content: pullStream}])
Error: content.once is not a function
@lidel
Copy link
Contributor

lidel commented Apr 19, 2018

Hm.. is this why interface-ipfs-core spec defines a separate ipfs.files.addPullStream?

@alanshaw alanshaw added the kind/bug A bug in existing code (including security flaws) label Apr 19, 2018
@olizilla
Copy link
Author

@lidel I agree, it is a little odd, but i think the api is meaningfully different from files.add...

  • ipfs.files.add(pullStream) should let you hand a pull-stream to ipfs add and get a ipfsFileRef object back
  • ipfs.files.addPullStream() returns a through pull stream, that should let you add things to ipfs as step in a larger pull stream chain.

Neither seems to work as expected currently.

@alanshaw
Copy link
Contributor

alanshaw commented Apr 20, 2018

Fixed here in: 9884f7c and ca48731

js-ipfs-api issue ipfs-inactive/js-ipfs-http-client#745 and PR ipfs-inactive/js-ipfs-http-client#746

js-ipfs issue ipfs/js-ipfs#1317 and PR ipfs/js-ipfs#1319

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug A bug in existing code (including security flaws)
Projects
None yet
Development

No branches or pull requests

3 participants