Binary and text payloads
Representing request or response payloads with an explicit MIME type.
Node.js · Class
Blob encapsulates immutable raw data that can be safely shared across worker threads. It combines string or binary parts and supports byte, text, ArrayBuffer, and stream-based reads.
The global Blob class stores immutable raw data assembled from strings or binary parts. Its size and MIME type are available synchronously; arrayBuffer(), bytes(), text(), and stream() provide asynchronous or streaming access to the content, while the original data remains safely shareable across worker threads.
new buffer.Blob([sources[, options]])| Name | Type | Description |
|---|---|---|
sources | string[] | ArrayBuffer[] | TypedArray[] | DataView[] | Blob[] | Array of strings, ArrayBuffer, TypedArray, DataView, or Blob values to concatenate into the new Blob. |
options | Object | Optional settings. endings may be transparent or native; type specifies the content type. |
A Blob instance containing the concatenated source data.
const blob = new Blob(["hello", " world"], { type: "text/plain" });
console.log(blob.size, blob.type);
console.log(await blob.text());
const bytes = await blob.bytes();
console.log(bytes.length);Creates a text Blob, inspects its metadata, reads it as UTF-8 text, and obtains its bytes.
Representing request or response payloads with an explicit MIME type.
Passing immutable data between worker threads through MessagePort.
Reading content as bytes, UTF-8 text, an ArrayBuffer, or a stream.
Blob.prototype.arrayBuffer()Blob.prototype.bytes()Blob.prototype.stream()Blob.prototype.text()MessagePort