ipfs
IPFS get and add streams.
Install
npm install @datastream/ipfs ipfsGetStream Readable async
Retrieves content from IPFS by CID.
Options
| Option | Type | Default | Description |
|---|---|---|---|
node | IPFS | — | IPFS node instance |
cid | string | — | Content 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
| Option | Type | Default | Description |
|---|---|---|---|
node | IPFS | — | IPFS node instance |
resultKey | string | "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...' }