Skip to content

Function: convertArrayBufferToBase64()

ts
function convertArrayBufferToBase64(arrayBuffer: ArrayBuffer): string;

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

Experimental

Convert an ArrayBuffer to a base64-encoded string.

Parameters

ParameterTypeDescription
arrayBufferArrayBufferThe ArrayBuffer to convert.

Returns

string

A base64-encoded string representing the buffer contents.

Example

ts
const response = await fetch('https://example.com/photo.png');
const buffer = await response.arrayBuffer();
const base64 = convertArrayBufferToBase64(buffer);
console.log(base64.slice(0, 20)); // first 20 chars of the encoded string

Matterway Assistant SDK Documentation