Name

Blob — an opaque chunk of data, such as file contents

Synopsis

A Blob is an opaque type used to exchange data between APIs. Blobs may be very large and may represent binary data, but neither is required. Blobs are often stored in files, but this is an implementation detail. Blobs expose only their size and, optionally, a MIME type, and they define a single method for treating a region of a Blob as a Blob.

A number of APIs use Blobs: see FileReader for a way to read the content of a Blob and BlobBuilder for a way to create new Blob objects. See XMLHttpRequest for ways to download and upload Blobs. See Blobs for discussion of Blobs and the APIs that use them.

Properties

readonly unsigned long size

The length, in bytes, of the Blob.

readonly string type

The MIME type of the Blob, if it has one, or the empty string otherwise.

Methods

Blob slice(unsigned long start, unsigned long length, [string contentType])

Return a new Blob that represents the length bytes of this Blob starting at offset start. If contentType is specified, it will be used as the type property of the returned Blob

Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.