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.

Read file error on Windows #1000

Closed
Closed
@EasonWang01

Description

@EasonWang01
  • Version: 0.4.10
  • Platform: OSX
const IPFS = require('ipfs')
const stream = require('stream');
const path = require('path');

const node = new IPFS()
node.on('ready', (cb) => {
  node.files.add({
    path: 'hello.txt',
    content: require('fs').readFileSync(path.join(__dirname, './ipfs.js'))
  }, (err, result) => {
    if (err) { return cb(err) }

    console.log('\nAdded file:', result[0].path, result[0].hash);
  })
})

then https://gateway.ipfs.io/ipfs/....hash
the browser will keep loading and not showing the file.

2.Is there an example that using Readstream to add file to ipfs?

something like

const IPFS = require('ipfs')
const stream = require('stream');
const path = require('path');

const node = new IPFS()
node.on('ready', (cb) => {
  node.files.add({
    content: fs.createReadStream('sample.txt', { start: 90, end: 99 })
  }, (err, result) => {
    if (err) { return cb(err) }

    console.log('\nAdded file:', result[0].path, result[0].hash)
    // process.exit()
  })
})

Because in the test example https://github.com/ipfs/interface-ipfs-core/blob/master/src/files.js

ipfs.files.createAddStream....

then load file using 

loadFixture(__dirname, '../test/fixtures/test-folder/pp.txt', 'interface-ipfs-core'),

but the loadFixture function still using

require('fs').readFileSync(path.join(dirname, file))

https://github.com/ipfs/aegir/blob/master/src/fixtures.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/supportA question or request for support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions