BlobBuilder

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Non-standard: This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

Note: The BlobBuilder interface has been deprecated in favor of the newly introduced Blob constructor.

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.

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);
File getFile(in DOMString name, [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.

getFile() Non-Standard

Returns a File object.

File getFile(
  in DOMString name,
  [optional] in DOMString contentType
);

Parameters

name

The file name.

contentType Optional

The MIME type of the data to be returned in the File. This will be the value of the File object's type property.

Return value

A File object.

Specifications

This feature is not part of any specification anymore. It is no more on track to become a standard.

Browser compatibility

BCD tables only load in the browser

See also