Blob: Blob() constructor
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Note: This feature is available in Web Workers.
The Blob() constructor returns a
new Blob object. The content of the blob consists of the concatenation
of the values given in the parameter blobParts.
Syntax
new Blob(blobParts)
new Blob(blobParts, options)
Parameters
blobPartsOptional-
An iterable object such as an
Array, havingArrayBuffers,TypedArrays,DataViews,Blobs, strings, or a mix of any of such elements, that will be put inside theBlob. Strings should be well-formed Unicode, and lone surrogates are sanitized using the same algorithm asString.prototype.toWellFormed(). optionsOptional-
An object which may specify any of the following properties:
typeOptional-
The MIME type of the data that will be stored into the blob. The default value is the empty string, (
""). endingsOptional-
How to interpret newline characters (
\n) within the contents, if the data is text. The default value,transparent, copies newline characters into the blob without changing them. To convert newlines to the host system's native convention, specify the valuenative.
Return value
A new Blob object containing the specified data.
Examples
const blobParts = ['<q id="a"><span id="b">hey!</span></q>']; // an array consisting of a single string
const blob = new Blob(blobParts, { type: "text/html" }); // the blob
Specifications
| Specification |
|---|
| File API> # constructorBlob> |
Browser compatibility
Loading…