Web/API/Blob/Blob

From Get docs
< Web/API‎ | Blob


The Blob() constructor returns a new Blob object. The content of the blob consists of the concatenation of the values given in the parameter array.

Syntax

var newBlob = new Blob(array, options);

Parameters

array
An Array of ArrayBuffer, ArrayBufferView, Blob, USVString objects, or a mix of any of such objects, that will be put inside the Blob. USVString objects are encoded as UTF-8.
options Optional
An optional object of type BlobPropertyBag which may specify any of the following properties:
type Optional
The MIME type of the data that will be stored into the blob. The default value is the empty string, ("").
endings Optional '
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 value native.

Return value

A new Blob object containing the specified data.

Example

var aFileParts = ['<a id="a"><b id="b">hey!</b></a>']; // an array consisting of a single DOMString
var oMyBlob = new Blob(aFileParts, {type : 'text/html'}); // the blob

Specification

Specification Status Comment
File APIThe definition of 'Blob()' in that specification. Working Draft Initial definition.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
Blob() constructor Chrome

Full support 20

Edge

Full support 12

Firefox Full support 13

Notes'

Full support 13

Notes'

Notes' Before Firefox 16, the second parameter, when set to null or undefined, leads to an error instead of being handled as an empty dictionary.

IE

Full support 10

Opera

Full support 12

Safari

Full support 8

WebView Android

Full support 37

Chrome Android

Full support 25

Firefox Android Full support 14

Notes'

Full support 14

Notes'

Notes' Before Firefox 16, the second parameter, when set to null or undefined, leads to an error instead of being handled as an empty dictionary.

Opera Android

Full support 12

Safari iOS

Full support 8

Samsung Internet Android

Full support 1.5

Legend

Full support  
Full support
See implementation notes.'
See implementation notes.


See also

  • The deprecated BlobBuilder interface which this constructor replaces.

Blob() by Mozilla Contributors is licensed under CC-BY-SA 2.5.