Skip to main content

Function: downloadFile()

downloadFile(options: FileDownloadOptions): void

Defined in: src/stores/sites/utils/fileDownload.ts:199

Triggers a file download in the browser.

Parametersโ€‹

optionsโ€‹

FileDownloadOptions

The file download options including buffer, fileName, and optional mimeType.

Returnsโ€‹

void

Remarksโ€‹

This function creates a Blob from the provided buffer and initiates a download using an anchor element. If the primary method fails, a fallback strategy is attempted.

Exampleโ€‹

downloadFile({
buffer: myArrayBuffer,
fileName: "report.txt",
mimeType: "text/plain",
});

Throwsโ€‹

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error If the download fails due to browser API issues or DOM manipulation errors.