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

files.add with pull stream does not work #1317

Closed
@alanshaw

Description

@alanshaw
  • 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions