Function: triggerDownload()
ts
function triggerDownload(
data,
fileName,
mimeType?
): void;Defined in: browser.ts:36
Prompts the browser to save data under fileName.
Creates a temporary object URL and clicks a hidden anchor, then cleans both up. The URL is revoked on the next tick rather than immediately, because revoking synchronously cancels the download in some browsers.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
data | Uint8Array<ArrayBufferLike> | Blob | undefined | The bytes to save. A Uint8Array is copied into a fresh buffer first, since a view into WebAssembly memory may cover more than it appears to and Blob would capture the whole thing. |
fileName | string | undefined | Name offered in the save dialog, extension included. |
mimeType | string | 'application/zip' | Content type for the blob. Defaults to application/zip. |
Returns
void
Throws
Outside a browser — in Node, write the bytes with fs.writeFile instead.
Example
ts
const zip = await writeShapefileZip(data, { fileName: 'parcels' });
triggerDownload(zip, 'parcels.zip');