过时
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

BlobBuilder interface provides an easy way to construct Blob objects. Just create a BlobBuilder and append chunks of data to it by calling the append() method. When you're done building your blob, call getBlob() to retrieve a Blob containing the data you sent into the blob builder.

注意: BlobBuilder interface has been deprecated in favor of the newly introduced Blob 构造函数。

方法概述

void append (in ArrayBuffer data);
void append (in Blob data);
void append (in String data, [optional] in String endings);
Blob getBlob ([optional] in DOMString contentType);
File getFile (in DOMString name, [optional] in DOMString contentType);

方法

append()

Appends the contents of the specified JavaScript object to the Blob being built. If the value you specify isn't a Blob , ArrayBuffer ,或 字符串 , the value is coerced to a string before being appended to the blob.

void append(
  in ArrayBuffer data
);
void append(
  in Blob data
);
void append(
  in String data,
  [optional] in String endings
);
					
参数
data
The data to append to the Blob being constructed.
endings
Specifies how strings containing \n are to be written out. This can be "transparent" (endings unchanged) or "native" (endings changed to match host OS filesystem convention). The default value is "transparent" .

getBlob()

返回 Blob object that has been constructed using the data passed through calls to append() .

Blob getBlob(
  in DOMString contentType Optional
);
					
参数
contentType 可选
The MIME type of the data to be returned in the Blob . This will be the value of the Blob object's type property.
返回值

A Blob object containing all of the data passed to any calls to append() made since the BlobBuilder was created. This also resets the BlobBuilder so that the next call to append() is starting a new, empty blob.

getFile()

返回 File 对象。

File getFile(
  in DOMString name,
  [optional] in DOMString contentType
);
						
参数
名称

The file name.

contentType 可选
The MIME type of the data to be returned in the File . This will be the value of the File object's type property.
返回值

A File 对象。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
BlobBuilder 弃用 非标 Chrome 8 Prefixed
8 Prefixed
Prefixed Implemented with the vendor prefix: Webkit
Edge 79 Prefixed
79 Prefixed
Prefixed Implemented with the vendor prefix: Webkit
不支持 ≤18 — 79
不支持 12 — 79 Prefixed
Prefixed Implemented with the vendor prefix: MS
Firefox 6 — 18 Prefixed
不支持 6 — 18 Prefixed
Prefixed Implemented with the vendor prefix: Moz
Starting in Firefox 14, using MozBlobBuilder will show a warning message in the web console that the use of MozBlobBuilder is deprecated and suggests to use Blob constructor instead.
IE 10 Prefixed
10 Prefixed
Prefixed Implemented with the vendor prefix: MS
Opera No Safari No WebView Android 3 Prefixed
3 Prefixed
Prefixed Implemented with the vendor prefix: Webkit
Chrome Android 18 Prefixed
18 Prefixed
Prefixed Implemented with the vendor prefix: Webkit
Firefox Android 6 — 18 Prefixed
不支持 6 — 18 Prefixed
Prefixed Implemented with the vendor prefix: Moz
Starting in Firefox 14, using MozBlobBuilder will show a warning message in the web console that the use of MozBlobBuilder is deprecated and suggests to use Blob constructor instead.
Opera Android No Safari iOS No Samsung Internet Android 1.0 Prefixed
1.0 Prefixed
Prefixed Implemented with the vendor prefix: Webkit

图例

完整支持

完整支持

不支持

不支持

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

弃用。不要用于新网站。

弃用。不要用于新网站。

见实现注意事项。

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

另请参阅

元数据

  • 最后修改:
  1. BlobBuilder
  2. 文件 API 相关页面
    1. Blob
    2. File
    3. FileList
    4. FileReader
    5. FileReaderSync

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1