ipfs

IPFS get and add streams.

Install

npm install @datastream/ipfs

ipfsGetStream Readable async

Retrieves content from IPFS by CID.

Options

OptionTypeDefaultDescription
nodeIPFSIPFS node instance
cidstringContent identifier

Example

import { pipeline } from '@datastream/core'
import { ipfsGetStream } from '@datastream/ipfs'

await pipeline([
  await ipfsGetStream({ node: ipfsNode, cid: 'QmHash...' }),
])

ipfsAddStream PassThrough async

Adds content to IPFS and returns the CID in .result().

Options

OptionTypeDefaultDescription
nodeIPFSIPFS node instance
resultKeystring"cid"Key in pipeline result

Result

The CID of the stored content.

Example

import { pipeline, createReadableStream } from '@datastream/core'
import { ipfsAddStream } from '@datastream/ipfs'

const result = await pipeline([
  createReadableStream('Hello IPFS!'),
  await ipfsAddStream({ node: ipfsNode }),
])

console.log(result)
// { cid: 'QmHash...' }