Skip to main content

Function: bufferToBlobPart()

bufferToBlobPart(input): ArrayBuffer

Defined in: packages/agentos/src/io/media/images/blobPart.ts:18

Converts a Node.js Buffer into a DOM-compatible BlobPart.

Recent TypeScript DOM typings require BlobPart byte views to be backed by a concrete ArrayBuffer, while Buffer is typed as ArrayBufferLike. A copy of the bytes in an ArrayBuffer of its own avoids that mismatch.

Parameters​

input​

Buffer

Raw image bytes stored in a Node.js Buffer.

Returns​

ArrayBuffer

An ArrayBuffer safe to pass into new Blob([...]).