Appearance
Function: convertBase64ToMwFile()
ts
function convertBase64ToMwFile(
data: string,
name: string,
type: string): MwFile;Defined in: src/file/mwFile.ts:79
Experimental
Create an MwFile from base64-encoded data.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | string | The base64-encoded file content. |
name | string | The file name, including extension. |
type | string | The MIME type of the file. |
Returns
An MwFile containing the decoded data and metadata.
Example
ts
const invoiceBase64 = await downloadInvoice('INV-2024-0042');
const invoice = convertBase64ToMwFile(
invoiceBase64,
'invoice-0042.pdf',
'application/pdf',
);
console.log(invoice.name); // 'invoice-0042.pdf'
console.log(invoice.size); // size in bytes