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
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
blobPartsList<Union44>optionsBlobPropertyBag
Remarks
Properties
Size
[Value("size")]
public ulong Size { get; }
Property Value
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's MIME type, or an empty string if the
type could not be determined.
Remarks
NOTE
Based on the current implementation, browsers won'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 "text/plain" and not "image/png". Moreover,blob.typeis 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.
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
-Response.ArrayBuffer
-Streams API
-ReadAsArrayBuffer(Blob)
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's called.
[Value("slice")]
public Blob Slice(long start = 0, long end = 0, string contentType = null)
Parameters
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
-Response.Body
-Streams API
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's data
as a text string. The data is always presumed to be in UTF-8 format.
Remarks
-Response.Text
-Streams API
-ReadAsText(Blob, string)