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

fix bug: node.files.add do not accept object #1255

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions examples/ipfs-101/1.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,28 @@ let fileMultihash
series([
(cb) => node.on('ready', cb),
(cb) => node.version((err, version) => {
if (err) { return cb(err) }
if (err) {
return cb(err)
}
console.log('Version:', version.version)
cb()
}),
(cb) => node.files.add({
path: 'hello.txt',
content: Buffer.from('Hello World 101')
}, (err, filesAdded) => {
if (err) { return cb(err) }

console.log('\nAdded file:', filesAdded[0].path, filesAdded[0].hash)
fileMultihash = filesAdded[0].hash
cb()
}),
(cb) => node.files.add(
Buffer.from('Hello World 101'),
(err, filesAdded) => {
if (err) {
return cb(err)
}
console.log('\nAdded file:', filesAdded[0].path, filesAdded[0].hash)
fileMultihash = filesAdded[0].hash
cb()
}),
(cb) => node.files.cat(fileMultihash, (err, data) => {
if (err) { return cb(err) }
if (err) {
return cb(err)
}

console.log('\nFile content:')
process.stdout.write(data)
})
])
])