Конструктор Blob()
возвращает новый объект Blob
. Содержимое blob состоит из объединенных значений, переданных в параметре array.
Синтаксис
var aBlob = new Blob( array, options );
Параметры
- array - массив
Array
из объектовArrayBuffer
,ArrayBufferView
,Blob
,DOMString
, или смесь любых из подобных объектов, которая может быть размещена внутриBlob
. DOMStrings представлены в кодировке UTF-8. - options is an optional
BlobPropertyBag
dictionary which may specify the following two attributes:type
, with a default value of""
, that represents the MIME type of the content of the array that will be put in the blob.endings
, with a default value of"transparent"
, that specifies how strings containing the line ending character\n
are to be written out. It is one of the two values:"native"
, meaning that line ending characters are changed to match host OS filesystem convention, or"transparent",
meaning that endings are stored in the blob without change.
Пример
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 | Status | Comment |
---|---|---|
File API Определение 'Blob()' в этой спецификации. |
Рабочий черновик | Initial definition. |
Браузерная совместимость
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 20 | 13.0 (13.0) [1] | 10 | 12.10 | 8 |
in Workers | ? | 14.0 (14.0) | ? | ? | ? |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | ? | 13.0 (13.0) [1] | Нет | ? | ? |
in Workers | ? | 14.0 (14.0) | Нет | ? | ? |
[1] Before Firefox 16, the second parameter, when set to null
or undefined
, leads to an error instead of being handled as an empty dictionary.
See also
- The deprecated
BlobBuilder
which this constructor replaces.