Table of Contents

Class Blob

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The Blob interface represents a blob, which is 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.

[Value("Blob")]
public class Blob
Inheritance
Blob
Derived
Inherited Members

Remarks

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.

-FileReader
-File
-URLcreateObjectURL
-Using files from web applications

See also on MDN

Constructors

Blob()

public Blob()

Blob(List<Union44>, BlobPropertyBag)

The Blob() constructor returns a
new Blob object. The content of the blob consists of the concatenation
of the values given in the parameter blobParts.

public Blob(List<Union44> blobParts = null, BlobPropertyBag options = null)

Parameters

blobParts List<Union44>
options BlobPropertyBag

Remarks

Properties

Size

The size read-only property of the Blob interface returns
the size of the Blob or File in bytes.

[Value("size")]
public ulong Size { get; }

Property Value

ulong

The number of bytes of data contained within the Blob (or
Blob-based object, such as a File).

Remarks

Type

The type read-only property of the Blob interface returns the {{Glossary("MIME type")}} of the file.

[Value("type")]
public string Type { get; }

Property Value

string

A string containing the file&apos;s MIME type, or an empty string if the
type could not be determined.

Remarks

NOTE

Based on the current implementation, browsers won&apos;t actually read the bytestream of a file to determine its media type.
It is assumed based on the file extension; a PNG image file renamed to .txt would give &quot;text/plain&quot; and not &quot;image/png&quot;. Moreover, blob.type is generally reliable only for common file types like images, HTML documents, audio and video.
Uncommon file extensions would return an empty string.
Client configuration (for instance, the Windows Registry) may result in unexpected values even for common types. Developers are advised not to rely on this property as a sole validation scheme.

-Blob
-Using files from web applications

See also on MDN

Methods

ArrayBuffer()

The arrayBuffer() method of the Blob
interface returns a Promise that resolves with the contents of the blob as
binary data contained in an ArrayBuffer().

[Value("arrayBuffer")]
public Task<ArrayBuffer> ArrayBuffer()

Returns

Task<ArrayBuffer>

A promise that resolves with an ArrayBuffer() that contains the blob's
data in binary form.

Remarks

Bytes()

The bytes() method of the Blob interface returns a {{jsxref("Promise")}} that resolves with a {{jsxref("Uint8Array")}} containing the contents of the blob as an array of bytes.

[Value("bytes")]
public Task<Uint8Array> Bytes()

Returns

Task<Uint8Array>

A Promise that fulfills with a Uint8Array object containing the blob data.

Remarks

Slice(long, long, string)

The slice() method of the Blob interface
creates and returns a new Blob object which contains data from a subset of
the blob on which it&apos;s called.

[Value("slice")]
public Blob Slice(long start = 0, long end = 0, string contentType = null)

Parameters

start long
end long
contentType string

Returns

Blob

A new Blob object containing the specified subset of the data contained
within the blob on which this method was called. The original blob is not altered.

Remarks

Stream()

The stream() method of the Blob interface returns a ReadableStream which upon reading returns the data contained within the Blob.

[Value("stream")]
public ReadableStream Stream()

Returns

ReadableStream

A ReadableStream which, upon reading, returns the contents of the
Blob.

Remarks

Text()

The text() method of the
Blob interface returns a {{jsxref("Promise")}} that resolves with a
string containing the contents of the blob, interpreted as UTF-8.

[Value("text")]
public Task<string> Text()

Returns

Task<string>

A promise that resolves with a string which contains the blob&apos;s data
as a text string. The data is always presumed to be in UTF-8 format.

Remarks