BlobBuilder

Deprecated

This is an experimental feature
Because this feature is still in development in some browsers, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental feature is subject to change in future version of browsers as the spec changes.

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 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 Optional

); 
Parameters
contentType Optional
The MIME type of the data to be returned in the Blob . This will be the value of the Blob object's type property.
Return value

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.

Browser compatibility

  • Desktop
  • Mobile

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 MozBlobBuilder will show a warning message in Web Console that the use of MozBlobBuilder is deprecated and use Blob constructor instead.
  • WebKit has deprecated WebKitBlobBuilder in favor of the Blob constructor. While Safari disables the feature in Nightly, Chrome appears to continue supporting it. (See this WebKit changeset for details).

Tags (3)

Edit tags

Attachments (0)

 

Attach file