Table of contents
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.
Note: The
BlobBuilder interface has been deprecated in favor of the newly introduced Blob
constructor; however, as of April 2012, no browser has support for the constructor in their shipping version.Method overview
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); |
Methods
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 };
Parameters
data- The data to append to the
Blobbeing constructed. endings- Specifies how strings containing
\nare 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 Optional
);
Parameters
- contentType Optional
- The MIME type of the data to be returned in the
Blob. This will be the value of theBlobobject's type property.
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | 8 As WebKitBlobBuilder † | 6.0 (6.0)
As MozBlobBuilder | 10 As MSBlobBuilder | -- | --† |
| Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | 3 As WebKitBlobBuilder | 6.0 (6.0) As MozBlobBuilder | -- | -- | -- |
Notes on BlobBuilder
- Starting in Firefox 14, using
MozBlobBuilderwill show a warning message in Web Console that the use ofMozBlobBuilderis deprecated and useBlobconstructor instead. - WebKit has deprecated
WebKitBlobBuilderin favor of theBlobconstructor. While Safari disables the feature in Nightly, Chrome appears to continue supporting it. (See this WebKit changeset for details).


Mozilla Developer Network