sdk.file_2.downloadfile
Home > @matterway/sdk > File_2 > downloadFile
File_2.downloadFile() function
Downloads a file by creating a temporary link element with the given file data and metadata and then simulating a click event to trigger a download.
Signature:
export declare function downloadFile(ctx: Context, file: SdkFile): Promise<void>;
Parameters
Parameter | Type | Description |
---|---|---|
ctx | Context | The Matterway SDK context. |
file | SdkFile | The SdkFile object containing the file data and metadata to be downloaded. |
Returns:
Promise<void>
Promise of void
Example
const file = { name: 'example.txt', data: 'SGVsbG8gV29ybGQh', type: 'text/plain' }; await downloadFile(context, file);