Skip to content

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

ParameterTypeDescription
uint8ArrayUint8ArrayThe raw bytes of the file.
namestringThe file name, including extension.
typestringThe MIME type of the file.

Returns

MwFile

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'

Matterway Assistant SDK Documentation