Skip to content

Function: convertArrayBufferToMwFile()

ts
function convertArrayBufferToMwFile(
   arrayBuffer: ArrayBuffer, 
   name: string, 
   type: string): MwFile;

Defined in: src/file/mwFile.ts:118

Experimental

Create an MwFile from an ArrayBuffer.

Parameters

ParameterTypeDescription
arrayBufferArrayBufferThe raw binary data for the file.
namestringThe file name, including extension.
typestringThe MIME type of the file.

Returns

MwFile

An MwFile containing the buffer data and metadata.

Example

ts
const response = await fetch('https://example.com/cat-photo.jpg');
const buffer = await response.arrayBuffer();
const catPhoto = convertArrayBufferToMwFile(buffer, 'cat-photo.jpg', 'image/jpeg');
console.log(catPhoto.size); // file size in bytes

Matterway Assistant SDK Documentation