What is a JSON blob

Blob

Overview

A is a file-like amount of immutable raw data that does not necessarily contain native JavaScript data. The interface is based on and extends its functions and the support of files on the user's system.

An easy way to create a blob is by calling the (en-US) constructor. In another way, it is also possible to obtain a section from another blob with the help of a call.

The APIs that accept blob objects are also mentioned in the documentation.

Note: The method had initially taken as the second argument to indicate the number of bytes to copy into the new. If you specified values ​​such that exceeded the size of the source, the returned contained data from the start index to the end of the source.

Please note: The method can be preceded by a vendor prefix in some browsers (and versions). Firefox 12 and earlier:. Safari:. An old version of without a vendor prefix is ​​obsolete. Support for was discontinued with Firefox 30.

Constructor

(en-US)
Returns a new one, the content of which is the composite array passed as a parameter.

properties

Read only
Returns a Boolean value that indicates whether the method has already been called on this. Closed blobs can no longer be read.
(en-US) Read-only
Returns the size of the content in bytes.
(en-US) Read-only
One that contains the MIME type. If the type is unknown, the return string is empty.

Methods

Examples:

Sample application of the Blob constructor

The (en-US) makes it possible to generate from objects. For example, you can create one from a String object:

(en-US) offers another option to create blobs, which is now out of date and should no longer be used.

Creating a url for a typed array through a blob

Example code:

Read data from a blob

To read data from a blob, a must be used. The following code reads the contents of a blob as a typed array.

Another method of allows you to read the content of a blob as a string or a data URL.

Specifications

Browser compatibility

Note on the slice () implementation

[1] A version of, which contains the desired size as a second argument, was implemented in WebKit and Opera 11.10. However, because this syntax was different from and, support in WebKit was dropped in favor of the new syntax of

[2] A variant of, which contains the desired size as the second argument, was available in Firefox 4. However, because this syntax was different from and, Gecko's support was dropped in favor of the new syntax from.

[3] Before Gecko 12.0 (Firefox 12.0 / Thunderbird 12.0 / SeaMonkey 2.9) an error occurred in the behavior of slice (); the first and last position outside the range of 64-bit values ​​were incorrectly processed, which has now been fixed for unsigned 64-bit values.

[4] See bug 1048325

Notes on Gecko

Before Gecko 12.0 (Firefox 12.0 / Thunderbird 12.0 / SeaMonkey 2.9) there was a bug that affected the behavior of. The method did not work for start and end positions outside of signed 64-bit values. This bug has now been fixed and unsigned 64-bit values ​​are now possible.

Chrome Code - Scope

To use blobs in Chrome Code, JSM and Bootstrap Scope, they have to be imported as follows:

are also available in worker scopes.

See also