Appearance
Function: convertUint8ArrayToMwFile()
ts
function convertUint8ArrayToMwFile(
uint8Array: Uint8Array,
name: string,
type: string): MwFile;Defined in: src/file/mwFile.ts:312
Convert a Uint8Array to an MwFile.
Converts the bytes to an ArrayBuffer, then wraps it as an MwFile.
Parameters
| Parameter | Type | Description |
|---|---|---|
uint8Array | Uint8Array | The raw bytes of the file. |
name | string | The file name, including extension. |
type | string | The MIME type of the file. |
Returns
An MwFile built from the Uint8Array data.
Example
ts
const pdfBytes = await pdfDoc.save();
const mwFile = convertUint8ArrayToMwFile(pdfBytes, 'report.pdf', 'application/pdf');
console.log(mwFile.name); // 'report.pdf'