downloadAndValidate
downloadAndValidate(
options):Promise<Uint8Array<ArrayBufferLike>>
Defined in: packages/synapse-core/src/piece/download.ts:63
Download data from a URL, validate its PieceCID, and return as Uint8Array
This function:
- Downloads data from the URL
- Calculates PieceCID during streaming
- Collects all chunks into a Uint8Array
- Validates the calculated PieceCID matches the expected value
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | OptionsType | downloadAndValidate.OptionsType |
Returns
Section titled “Returns”Promise<Uint8Array<ArrayBufferLike>>
Data downloadAndValidate.ReturnType
Throws
Section titled “Throws”Errors downloadAndValidate.ErrorType
Example
Section titled “Example”import * as Piece from '@filoz/synapse-core/piece'const data = await Piece.downloadAndValidate({ url: 'https://example.com/piece', expectedPieceCid: 'bafkzcib...',})console.log(data)