Skip to content

uploadPieces

uploadPieces(client, options): Promise<OutputType>

Defined in: packages/synapse-core/src/sp/upload-pieces.ts:80

Upload pieces to an existing data set and add them in one signed request.

Streams each piece to the data set’s provider (concurrency at a time), then adds every parked piece in one add-pieces request and waits for it to be confirmed. Pieces that fail to upload, or whose add-pieces transaction is not confirmed, are returned in failed; the others are still added. Throws when no piece could be uploaded and added.

ParameterTypeDescription
clientClient<Transport, Chain, Account>The client to sign with.
optionsOptionsTypeuploadPieces.OptionsType

Promise<OutputType>

The confirmations, the added pieces and the failed ones. uploadPieces.OutputType

import * as SP from '@filoz/synapse-core/sp'
const { pieces, failed } = await SP.uploadPieces(client, {
dataSet,
pieces: files.map((file) => ({ data: file, metadata: { name: file.name } })),
})