--- title: BlobBuilder slug: Web/API/BlobBuilder translation_of: Web/API/BlobBuilder ---
{{ deprecated_header() }}
{{ SeeCompatTable() }}
The BlobBuilder
interface provides an easy way to construct {{ domxref("Blob") }} objects. Just create a BlobBuilder
and append chunks of data to it by calling the {{ manch("append") }} method. When you're done building your blob, call {{ manch("getBlob") }} to retrieve a {{ domxref("Blob") }} containing the data you sent into the blob builder.
BlobBuilder
接口已经废弃,请使用新版草案中引入的 {{domxref('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); |
Appends the contents of the specified JavaScript object to the {{ domxref("Blob") }} being built. If the value you specify isn't a {{ domxref("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
endings
\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"
.Returns the {{ domxref("Blob") }} object that has been constructed using the data passed through calls to {{ manch("append") }}.
Blob getBlob( in DOMString contentType {{ optional_inline() }} );
Blob
object's type property.A {{ domxref("Blob") }} object containing all of the data passed to any calls to {{ manch("append") }} made since the BlobBuilder
was created. This also resets the BlobBuilder
so that the next call to {{ manch("append") }} is starting a new, empty blob.
返回一个{{ domxref("File") }}对象.
File getFile( in DOMString name, [optional] in DOMString contentType );
的File
对象的type属性的值.一个{{ domxref("File") }}对象.
{{ CompatibilityTable() }}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 8 As WebKitBlobBuilder † |
{{ CompatGeckoDesktop("6.0") }} As MozBlobBuilder |
10 As MSBlobBuilder |
{{ CompatNo() }} | {{ CompatNo() }}† |
getfile() {{ non-standard_inline() }} |
{{ CompatNo() }} | {{ CompatGeckoDesktop("8.0") }} | {{ CompatNo() }} | {{ CompatNo() }} | {{ CompatNo() }} |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | 3 As WebKitBlobBuilder |
{{ CompatGeckoMobile("6.0") }} As MozBlobBuilder |
{{ CompatNo() }} | {{ CompatNo() }} | {{ CompatNo() }} |
getfile() {{ non-standard_inline() }} |
{{ CompatNo() }} | {{ CompatGeckoMobile("8.0") }} | {{ CompatNo() }} | {{ CompatNo() }} | {{ CompatNo() }} |
MozBlobBuilder
会在Web控制台显示一条警告消息: MozBlobBuilder
已被废弃,请使用{{ domxref("Blob") }}来代替.MozBlobBuilder
已被删除.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).