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

ipfs.files.addReadableStream() won't read streams #27

Closed
olizilla opened this issue Apr 19, 2018 · 1 comment
Closed

ipfs.files.addReadableStream() won't read streams #27

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

Comments

@olizilla
Copy link

Probably related to #26

When calling ipfs.files.addReadableStream(), as in the code below, the data event never fires. This happens when ipfs-companion is pointing at either an embedded js-ipfs and and external ipfs node. Using a local js-ipfs node, it works.

    addFileToIpfsAsReadableStream = async (file) => {
      return new Promise((resolve, reject) => {
        const {ipfs} = this.props
        const ipfsStream = ipfs.files.addReadableStream()
        ipfsStream.on('data', ipfsRef => {
          console.log('stream data', {ipfsRef})
          resolve(ipfsRef)
        })
        ipfsStream.on('error', reject)
        ipfsStream.write({content: fileStream(file), path: `/${file.name}`})
        ipfsStream.end()
        console.log('called stream end')
      })
    }

file is an html File object, and fileStream is and instance of https://github.com/maxogden/filereader-stream

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

Regular streams are converted to pull streams in ipfs-postmsg-proxy. The issue in this case is a combination of:

a) the problem resolved by 9884f7c and ipfs/ipfs-companion#465 in companion
b) the problem identified in this issue ipfs-inactive/js-ipfs-http-client#745.

Closing this issue as there is nothing further to fix in ipfs-postmsg-proxy

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

2 participants