Skip to content

@sqlrooms/utils / downloadFile

Function: downloadFile()

downloadFile(url, opts?): Promise<Uint8Array<ArrayBufferLike>>

Downloads a file from a specified URL using XMLHttpRequest

Parameters

ParameterTypeDescription
urlstringThe URL to download the file from
opts?{ method: string; headers: Record<string, string>; onProgress: (info) => void; }Optional configuration for the download
opts.method?stringThe HTTP method to use
opts.headers?Record<string, string>Additional headers to include in the request
opts.onProgress?(info) => voidCallback function to track download progress

Returns

Promise<Uint8Array<ArrayBufferLike>>

The downloaded file as a Uint8Array

Throws

Throws an object containing status and error message if download fails