< apis‎ | file
Jump to: navigation, search


This article is Ready to Use.

W3C Working Draft


The Blob object represents immutable raw data. It provides a method to slice data objects between ranges of bytes into further chunks of raw data.


Blob provides an attribute representing the size of the chunk of data. The File object inherits from the Blob object. Blob objects can be read asynchronously only on the main thread via FileReader objects, but metadata access via attributes such as size and type return synchronously (this trade-off is based on the underlying assumption that metadata access will not significantly block or disrupt the browser's main thread, whereas reading Blob data will).


No properties.


API Name Summary
close Releases the file lock for the associated file resource or frees the memory for the Blob object. After calling this method, performing addition operations on the Blob object fails and throws an exception.
slice Returns a new Blob object with bytes ranging from its optional start parameter up to but not including its optional end parameter.


No events.


// Example for creating a URL to a typed array using a blob


var typedArray = GetTheTypedArraySomehow();
var blob = new Blob([typedArray], {type: "application/octet-binary"}); // pass a useful mime type here
var url = URL.createObjectURL(blob);
// url will be something like: blob:d3958f5c-0777-0845-9dcf-2cb28783acaf
// now you can use the url in any context that regular URLs can be used in, for example img.src, etc.

// Blob constructor example usage


var aFileParts = ['<a id="a">hey!</a>'];
var oMyBlob = new Blob(aFileParts, { "type" : "text/xml" }); // the blob

Related specifications

Specification Status Related Changes
W3C File API Specification W3C Working Draft

See also

Other articles

Saving files locally using Blob and msSaveBlob


This article contains content originally from external sources.

Portions of this content come from the Mozilla Developer Network
Error creating thumbnail: File missing
: [Blob Article]

Portions of this content come from the Microsoft Developer Network: [blob constructor Article]