Blob()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

Конструктор 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. Не стандартно

Пример

js
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
File API
# constructorBlob

Совместимость с браузерами

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
Blob() constructor

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.
Has more compatibility info.

Смотрите также

  • The deprecated BlobBuilder which this constructor replaces.