ipfs-unixfs-engine
JavaScript implementation of the unixfs Engine used by IPFS
Last updated 6 years ago by achingbrain .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install ipfs-unixfs-engine 
SYNC missed versions from official npm registry.

ipfs-unixfs-engine

standard-readme compliant Jenkins Codecov Dependency Status js-standard-style

JavaScript implementation of the layout and chunking mechanisms used by IPFS to handle Files

Lead Maintainer

Alex Potsides

Table of Contents

Install

> npm install ipfs-unixfs-engine

Usage

The unixfs-engine exports the unixfs-importer and unixfs-exporter modules. Please see those modules for for full documentation.

Importing a file

The importer is a pull-stream through which takes objects of the form { path, content } where path is a string path and content can be a Buffer, a ReadableStream or a pull-stream that emits Buffers.

It requires an ipld resolver to persist DAGNodes and make them available over IPFS.

See the unixfs-importer module for full documentation.

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 file

The exporter is a pull-stream source which takes a cid and an ipld resolver.

See the unixfs-exporter module for full documentation.

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
  })
)

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

License

MIT

Current Tags

  • 0.35.4                                ...           latest (6 years ago)

80 Versions

  • 0.35.4                                ...           6 years ago
  • 0.35.3                                ...           6 years ago
  • 0.35.2                                ...           6 years ago
  • 0.35.1                                ...           6 years ago
  • 0.35.0                                ...           6 years ago
  • 0.34.0                                ...           6 years ago
  • 0.33.0                                ...           6 years ago
  • 0.32.8                                ...           6 years ago
  • 0.32.7                                ...           6 years ago
  • 0.32.6                                ...           6 years ago
  • 0.32.5                                ...           6 years ago
  • 0.32.4                                ...           6 years ago
  • 0.32.3                                ...           6 years ago
  • 0.32.2                                ...           6 years ago
  • 0.32.1                                ...           6 years ago
  • 0.32.0                                ...           6 years ago
  • 0.31.3                                ...           6 years ago
  • 0.30.2                                ...           6 years ago
  • 0.31.2                                ...           6 years ago
  • 0.31.1                                ...           6 years ago
  • 0.31.0                                ...           6 years ago
  • 0.30.1                                ...           6 years ago
  • 0.30.0                                ...           6 years ago
  • 0.29.0                                ...           7 years ago
  • 0.28.1                                ...           7 years ago
  • 0.28.0                                ...           7 years ago
  • 0.27.0                                ...           7 years ago
  • 0.26.0                                ...           7 years ago
  • 0.25.0                                ...           7 years ago
  • 0.24.4                                ...           7 years ago
  • 0.24.3                                ...           7 years ago
  • 0.24.2                                ...           7 years ago
  • 0.24.1                                ...           7 years ago
  • 0.24.0                                ...           7 years ago
  • 0.23.1                                ...           7 years ago
  • 0.23.0                                ...           7 years ago
  • 0.22.5                                ...           7 years ago
  • 0.22.4                                ...           7 years ago
  • 0.22.3                                ...           7 years ago
  • 0.22.2                                ...           7 years ago
  • 0.22.1                                ...           7 years ago
  • 0.22.0                                ...           7 years ago
  • 0.21.0                                ...           7 years ago
  • 0.20.0                                ...           7 years ago
  • 0.19.2                                ...           7 years ago
  • 0.19.1                                ...           8 years ago
  • 0.19.0                                ...           8 years ago
  • 0.18.0                                ...           8 years ago
  • 0.17.0                                ...           8 years ago
  • 0.16.1                                ...           8 years ago
  • 0.16.0                                ...           8 years ago
  • 0.15.4                                ...           8 years ago
  • 0.15.3                                ...           8 years ago
  • 0.15.2                                ...           8 years ago
  • 0.15.1                                ...           8 years ago
  • 0.15.0                                ...           8 years ago
  • 0.14.2                                ...           8 years ago
  • 0.14.1                                ...           8 years ago
  • 0.14.0                                ...           8 years ago
  • 0.13.0                                ...           8 years ago
  • 0.12.0                                ...           8 years ago
  • 0.11.4                                ...           8 years ago
  • 0.11.3                                ...           8 years ago
  • 0.11.2                                ...           8 years ago
  • 0.11.1                                ...           8 years ago
  • 0.11.0                                ...           8 years ago
  • 0.10.2                                ...           8 years ago
  • 0.10.1                                ...           8 years ago
  • 0.10.0                                ...           8 years ago
  • 0.9.0                                ...           8 years ago
  • 0.8.0                                ...           8 years ago
  • 0.7.0                                ...           8 years ago
  • 0.6.1                                ...           9 years ago
  • 0.6.0                                ...           9 years ago
  • 0.5.0                                ...           9 years ago
  • 0.4.5                                ...           9 years ago
  • 0.4.4                                ...           9 years ago
  • 0.4.3                                ...           9 years ago
  • 0.4.2                                ...           9 years ago
  • 0.4.1                                ...           9 years ago
Maintainers (1)
Downloads
Total 1
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (3)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE