在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:ipfs-inactive/js-ipfs-unixfs-engine开源软件地址:https://github.com/ipfs-inactive/js-ipfs-unixfs-engine开源编程语言:JavaScript 100.0%开源软件介绍:[ARCHIVED]
ipfs-unixfs-engine
Lead MaintainerTable of ContentsInstall
UsageThe Importing a fileThe importer is a pull-stream through which takes objects of the form It requires an ipld resolver to persist DAGNodes and make them available over IPFS. See the const {
importer
} = require('ipfs-unixfs-engine')
const pull = require('pull-stream')
const fs = require('fs')
// Import path /tmp/bar.txt
pull(
pull.values([{
path: '/tmp/bar.txt',
content: fs.createReadStream('/tmp/bar.txt')
}]),
// You need to create and pass an ipld resolver instance
// https://npmjs.com/packages/ipld
importer(<ipld-resolver instance>, <options>),
// Handle the error and do something with the results
pull.collect((err, files) => {
console.info(files)
// Prints:
// [{
// size: 12,
// leafSize: 4,
// multihash: <Buffer>
// path: '/tmp/bar.txt',
// name: ''
// }, {
// path: 'tmp',
// multihash: <Buffer>
// size: 65
// }]
})
) Exporting a fileThe exporter is a pull-stream source which takes a cid and an ipld resolver. See the const {
exporter
} = require('ipfs-unixfs-engine').exporter
const pull = require('pull-stream')
const drain = require('pull-stream/sinks/drain')
pull(
// You need to create and pass an ipld resolver instance
// https://npmjs.com/packages/ipld
exporter(cid, ipld),
drain((file) => {
// file.content is a pull stream containing the bytes of the file
})
) ContributeFeel free to join in. All welcome. Open an issue! This repository falls under the IPFS Code of Conduct. License |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论