Class: FBlob
Extends
FBase
Methods
copyBlob()
copyBlob(): FBlob
Returns a copy of this blob.
Returns
a new blob by copying the current blob
Example
const blob = univerAPI.newBlob(blob);
const newBlob = blob.copyBlob();
console.log(newBlob);
getAs()
getAs(contentType): FBlob
Return the data inside this object as a blob converted to the specified content type.
Parameters
Parameter | Type | Description |
---|---|---|
contentType | string | the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types |
Returns
a new blob by converting the current blob to the specified content type
Example
const blob = univerAPI.newBlob(blob);
const newBlob = blob.getBlob();
getBytes()
getBytes(): Promise<Uint8Array>
Gets the data stored in this blob.
Returns
Promise
<Uint8Array
>
the blob content as a byte array
Example
const blob = univerAPI.newBlob(blob);
const newBlob = blob.getBytes();
console.log(newBlob);
getContentType()
getContentType(): string
Gets the content type of the data stored in this blob.
Returns
string
the content type
Example
const blob = univerAPI.newBlob(blob);
const newBlob = blob.getContentType();
console.log(newBlob);
getDataAsString()
Call Signature
getDataAsString(): Promise<string>
Get the blob as a string.
Returns
Promise
<string
>
Example
const blob = univerAPI.newBlob(blob);
const newBlob = blob.getDataAsString();
console.log(newBlob);
Call Signature
getDataAsString(charset?): Promise<string>
Get the blob as a string.
Parameters
Parameter | Type | Description |
---|---|---|
charset ? | string | the charset |
Returns
Promise
<string
>
the blob content as a string
Example
const blob = univerAPI.newBlob(blob);
const newBlob = blob.getDataAsString('iso-8859-1');
console.log(newBlob);
setBytes()
setBytes(bytes): FBlob
Sets the data stored in this blob.
Parameters
Parameter | Type | Description |
---|---|---|
bytes | Uint8Array | a byte array |
Returns
the blob object
Example
const blob = univerAPI.newBlob();
const bytes = new Uint8Array(10);
blob.setBytes(bytes);
setContentType()
setContentType(contentType): FBlob
Sets the content type of the data stored in this blob.
Parameters
Parameter | Type | Description |
---|---|---|
contentType | string | the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types |
Returns
the blob object
Example
const blob = univerAPI.newBlob(blob);
const newBlob = blob.setContentType('text/plain');
console.log(newBlob);
setDataFromString()
Call Signature
setDataFromString(data): FBlob
Sets the data stored in this blob.
Parameters
Parameter | Type | Description |
---|---|---|
data | string | blob data string |
Returns
the blob object
Example
const blob = univerAPI.newBlob();
blob.setDataFromString('Hello, World!');
Call Signature
setDataFromString(data, contentType?): FBlob
Sets the data stored in this blob.
Parameters
Parameter | Type | Description |
---|---|---|
data | string | a string |
contentType ? | string | the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types |
Returns
the blob object
Example
const blob = univerAPI.newBlob();
blob.setDataFromString('Hello, World!', 'text/plain');