Skip to content

downloadAndValidateFromUrl

function downloadAndValidateFromUrl(url, expectedPieceCid): Promise<Uint8Array<ArrayBufferLike>>;

Defined in: packages/synapse-sdk/src/piece/download.ts:125

Download data from a URL, validate its PieceCID, and return as Uint8Array

This is a convenience function that fetches from a URL and then uses downloadAndValidate to download and validate the data.

ParameterTypeDescription
urlstringThe URL to download from
expectedPieceCidstring | PieceLinkThe expected PieceCID to validate against

Promise<Uint8Array<ArrayBufferLike>>

The downloaded data as a Uint8Array

Error if PieceCID validation fails or download errors occur

const data = await downloadAndValidateFromUrl(
'https://provider.com/piece/bafkzcib...',
'bafkzcib...'
)