Blob Class

An immutable sequence of bytes with a type (https://w3c.github.io/FileAPI/#blob-section). The parts of the constructor are strings (encoded as UTF-8), blobs, byte arrays and ReadOnlyMemory<T> of bytes. A blob can be referenced by a blob: URL (Url.CreateObjectUrl). stream() and textStream() are defined by the WebIDL bindings, with the streams implemented in JavaScript (docs/scripting.md#streams).

public class Blob

Constructors

NameDescription
Blob(IReadOnlyList<object>?, BlobPropertyBag?)Creates a blob from the given parts (strings, blobs or bytes) and options.

Blob(IReadOnlyList<object>?, BlobPropertyBag?)

Blob.cs

Creates a blob from the given parts (strings, blobs or bytes) and options.

public Blob(IReadOnlyList<object>? blobParts = null, BlobPropertyBag? options = null)

Properties

NameDescription
SizeGets the size of the blob, in bytes.
TypeGets the media type of the blob, or an empty string when it is unknown.

Gets the size of the blob, in bytes.

public ulong Size { get; }

Gets the media type of the blob, or an empty string when it is unknown.

public string Type { get; }

Methods

NameDescription
ArrayBuffer()Returns a copy of the content (an ArrayBuffer in JavaScript, https://w3c.github.io/FileAPI/#arraybuffer-method-algo).
Bytes()Returns a copy of the content (a Uint8Array in JavaScript, https://w3c.github.io/FileAPI/#bytes-method-algo).
Slice(long?, long?, string?)https://w3c.github.io/FileAPI/#dfn-slice
Text()Returns the content decoded as UTF-8, without the byte order mark (https://w3c.github.io/FileAPI/#text-method-algo).

ArrayBuffer()

Blob.cs

Returns a copy of the content (an ArrayBuffer in JavaScript, https://w3c.github.io/FileAPI/#arraybuffer-method-algo).

public Task<byte[]> ArrayBuffer()

Bytes()

Blob.cs

Returns a copy of the content (a Uint8Array in JavaScript, https://w3c.github.io/FileAPI/#bytes-method-algo).

public Task<byte[]> Bytes()

Slice(long?, long?, string?)

Blob.cs

https://w3c.github.io/FileAPI/#dfn-slice

public Blob Slice(long? start = null, long? end = null, string? contentType = null)

Parameters

start long?
end long?
contentType string?

Returns

Blob

See also

Text()

Blob.cs

Returns the content decoded as UTF-8, without the byte order mark (https://w3c.github.io/FileAPI/#text-method-algo).

public Task<string> Text()