Skip to Content
ClassesFBlob

Class: FBlob

Extends

  • FBase

Methods

copyBlob()

copyBlob(): FBlob

Returns a copy of this blob.

Returns

FBlob

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

ParameterTypeDescription
contentTypestringthe content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types

Returns

FBlob

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
ParameterTypeDescription
charset?stringthe 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

ParameterTypeDescription
bytesUint8Arraya byte array

Returns

FBlob

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

ParameterTypeDescription
contentTypestringthe content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types

Returns

FBlob

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
ParameterTypeDescription
datastringblob data string
Returns

FBlob

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
ParameterTypeDescription
datastringa string
contentType?stringthe content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
Returns

FBlob

the blob object

Example
const blob = univerAPI.newBlob(); blob.setDataFromString('Hello, World!', 'text/plain');