BlobBuilder - Web API 接口参考 编辑

已废弃
该特性已经从 Web 标准中删除,虽然一些浏览器目前仍然支持它,但也许会在未来的某个时间停止支持,请尽量不要使用该特性。

这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。

The 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接口已经废弃,请使用新版草案中引入的 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, or String, 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()

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

Blob getBlob(
  in DOMString contentType 可选
);
参数
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
);
参数
name
文件名.
contentType 可选
设置返回的File对象中的数据的MIME类型.这个值将会成为返回的File对象的type属性的值.
返回值

一个File对象.

浏览器兼容性

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!
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support8
As WebKitBlobBuilder
6.0 (6.0)
As MozBlobBuilder
10
As MSBlobBuilder
未实现未实现†
getfile() 未实现8.0 (8.0)未实现未实现未实现
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support3
As WebKitBlobBuilder
6.0 (6.0)
As MozBlobBuilder
未实现未实现未实现
getfile() 未实现8.0 (8.0)未实现未实现未实现

注:BlobBuilder已被废弃

  • 从Firefox 14开始,使用MozBlobBuilder会在Web控制台显示一条警告消息: MozBlobBuilder已被废弃,请使用Blob来代替.
  • 从Firefox 18开始,MozBlobBuilder已被删除.
  • WebKit has deprecated WebKitBlobBuilder and has made its support configurable. Currently Safari disables the feature in Nightly, so it will never likely to ship in the final version. On the other hand, Chrome, which has supported it since Chrome 8, still enables the feature. So Chrome might continue to support the feature. (See this WebKit changeset for details).

相关链接

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:134 次

字数:11996

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文