Skip to content

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.

Parameter Type Description
options OptionsType downloadAndValidate.OptionsType

Promise<Uint8Array<ArrayBufferLike>>

Data downloadAndValidate.ReturnType

Errors downloadAndValidate.ErrorType

import * as Piece from '@filoz/synapse-core/piece'
const data = await Piece.downloadAndValidate({
  url: 'https://example.com/piece',
  expectedPieceCid: 'bafkzcib...',
})
console.log(data)