Skip to content

createPieceCIDStream

createPieceCIDStream(): object

Defined in: packages/synapse-core/src/piece.ts:300

Create a TransformStream that calculates PieceCID while streaming data through it This allows calculating PieceCID without buffering the entire data in memory

object

An object with the TransformStream and a getPieceCID function to retrieve the result

getPieceCID: () => PieceLink | null

PieceLink | null

stream: TransformStream<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>

const { stream, getPieceCID } = createPieceCIDStream()
await fetch(url, {
method: 'PUT',
body: dataStream.pipeThrough(stream)
})
const pieceCid = getPieceCID() // Available after stream completes