downloadAndValidate
downloadAndValidate(
options):Promise<Uint8Array<ArrayBufferLike>>
Defined in: packages/synapse-core/src/piece/download.ts:201
Download data from a URL, validate its PieceCID, and return as Uint8Array
Reads downloadStream into memory, so the whole piece must fit in memory. Use downloadStream for large pieces.
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)