Blob

@native @JSGlobal @JSType
class Blob(blobParts: Iterable[BlobPart], options: BlobPropertyBag) extends Object

A Blob object represents a file-like object of immutable, raw data; they can be read as text or binary data, or converted into a ReadableStream so its methods can be used for processing the data. Blobs can represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system.

To construct a Blob from other non-blob objects and data, use the Blob() constructor. To create a blob that contains a subset of another blob's data, use the slice() method. To obtain a Blob object for a file on the user's file system, see the File documentation.

The APIs accepting Blob objects are also listed in the File documentation.

Companion:
object
class Object
trait Any
class Object
trait Matchable
class Any
class File

Value members

Concrete methods

def `type`: String

A string indicating the MIME type of the data contained in the Blob. If the type is unknown, this string is empty.

A string indicating the MIME type of the data contained in the Blob. If the type is unknown, this string is empty.

def arrayBuffer(): Promise[ArrayBuffer]

Returns a promise that resolves with an ArrayBuffer containing the entire contents of the blob as binary data.

Returns a promise that resolves with an ArrayBuffer containing the entire contents of the blob as binary data.

def size: Double

The size, in bytes, of the data contained in the Blob object.

The size, in bytes, of the data contained in the Blob object.

def slice(start: Double, end: Double, contentType: String): Blob

Creates and returns a new Blob object which contains data from a subset of the blob on which it's called.

Creates and returns a new Blob object which contains data from a subset of the blob on which it's called.

def stream(): ReadableStream[Uint8Array]

Returns a ReadableStream that can be used to read the contents of the blob.

Returns a ReadableStream that can be used to read the contents of the blob.

def text(): Promise[String]

Returns a promise that resolves with a USVString containing the entire contents of the blob interpreted as UTF-8 text.

Returns a promise that resolves with a USVString containing the entire contents of the blob interpreted as UTF-8 text.

See also:

Deprecated methods

@deprecated("This method seems to have been added in error and not actually exist.", "1.2.0")
def close(): Unit
Deprecated

Inherited methods

def hasOwnProperty(v: String): Boolean
Inherited from:
Object
def isPrototypeOf(v: Object): Boolean
Inherited from:
Object
def propertyIsEnumerable(v: String): Boolean
Inherited from:
Object
def toLocaleString(): String
Inherited from:
Object
def valueOf(): Any
Inherited from:
Object