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

files.add with pull stream does not work #1317

Closed
alanshaw opened this issue Apr 20, 2018 · 0 comments · Fixed by #1319
Closed

files.add with pull stream does not work #1317

alanshaw opened this issue Apr 20, 2018 · 0 comments · Fixed by #1319
Assignees

Comments

@alanshaw
Copy link
Member

alanshaw commented Apr 20, 2018

  • Version: 0.28.0
  • Platform: macOS Node.js 9.11.1
  • Subsystem: files

Type: Bug

Severity: High

Description:

Using files.add(pull stream) does not work

Steps to reproduce the error:

  1. add with pull stream (promise)

    const pull = require('pull-stream')
    const Ipfs = require('ipfs')
    const ipfs = new Ipfs
    
    ipfs.on('ready', () => {
        ipfs.files.add(pull.values([Buffer.from('test')]))
          .then(console.log)
          .catch(console.error)
    })

    output:

      /Users/alan/Desktop/test/ipfs-pull.test.js:31
          .then(console.log)
          ^
    
      TypeError: Cannot read property 'then' of undefined
          at IPFS.ipfs.on (/Users/alan/Desktop/test/ipfs-pull.test.js:31:5)
          at IPFS.emit (events.js:180:13)
          at done (/Users/alan/Desktop/test/node_modules/ipfs/src/core/boot.js:61:10)
          at /Users/alan/Desktop/test/node_modules/async/internal/parallel.js:39:9
          at /Users/alan/Desktop/test/node_modules/async/internal/once.js:12:16
          at replenish (/Users/alan/Desktop/test/node_modules/async/internal/eachOfLimit.js:59:25)
          at iterateeCallback (/Users/alan/Desktop/test/node_modules/async/internal/eachOfLimit.js:49:17)
          at /Users/alan/Desktop/test/node_modules/async/internal/onlyOnce.js:12:16
          at /Users/alan/Desktop/test/node_modules/async/internal/parallel.js:36:13
          at done (/Users/alan/Desktop/test/node_modules/ipfs/src/core/components/start.js:20:7)
    
  2. add with pull stream (callback)

    const pull = require('pull-stream')
    const Ipfs = require('ipfs')
    const ipfs = new Ipfs
    
    ipfs.on('ready', () => {
        ipfs.files.add(pull.values([Buffer.from('test')]), console.log)
    })

    output:

    Error: Invalid arguments, data must be an object, Buffer or readable stream
        at Function.add.promisify (/Users/alan/Desktop/test/node_modules/ipfs/src/core/components/files.js:199:25)
        at Object.add (/Users/alan/Desktop/test/node_modules/promisify-es6/index.js:32:27)
        at IPFS.ipfs.on (/Users/alan/Desktop/test/ipfs-pull.test.js:46:14)
        at IPFS.emit (events.js:180:13)
        at done (/Users/alan/Desktop/test/node_modules/ipfs/src/core/boot.js:61:10)
        at /Users/alan/Desktop/test/node_modules/async/internal/parallel.js:39:9
        at /Users/alan/Desktop/test/node_modules/async/internal/once.js:12:16
        at replenish (/Users/alan/Desktop/test/node_modules/async/internal/eachOfLimit.js:59:25)
        at iterateeCallback (/Users/alan/Desktop/test/node_modules/async/internal/eachOfLimit.js:49:17)
        at /Users/alan/Desktop/test/node_modules/async/internal/onlyOnce.js:12:16
    

Note that the following cases are successful:

  1. addPullStream with chunks of { content: [pull stream] }
  2. add with [{ content: [pull stream] }]

Files spec (which allows these combinations) for reference: https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md

@ghost ghost assigned alanshaw Apr 20, 2018
@ghost ghost added the status/in-progress In progress label Apr 20, 2018
@ghost ghost removed the status/in-progress In progress label May 6, 2018
This was referenced Nov 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant