Skip to Content
ClassesFBlob

类: FBlob

继承

  • FBase

方法

copyBlob()

copyBlob(): FBlob

Returns a copy of this blob.

返回

FBlob

a new blob by copying the current blob

示例

const blob = univerAPI.newBlob(); 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.

参数

参数类型描述
contentTypestringthe content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types

返回

FBlob

a new blob by converting the current blob to the specified content type

示例

const blob = univerAPI.newBlob(); const newBlob = blob.getAs('text/plain'); console.log(newBlob);

getBytes()

getBytes(): Promise<Uint8Array<...>>

Gets the data stored in this blob.

返回

Promise<Uint8Array<…>>

the blob content as a byte array

示例

const blob = univerAPI.newBlob(); const bytes = await blob.getBytes(); console.log(bytes);

getContentType()

getContentType(): string

Gets the content type of the data stored in this blob.

返回

string

the content type

示例

const blob = univerAPI.newBlob(); const contentType = blob.getContentType(); console.log(contentType);

getDataAsString()

调用签名

getDataAsString(): Promise<string>

Get the blob as a string.

返回

Promise<string>

示例
const blob = univerAPI.newBlob(); const data = await blob.getDataAsString(); console.log(data);

调用签名

getDataAsString(charset?): Promise<string>

Get the blob as a string.

参数
参数类型描述
charset?stringthe charset
返回

Promise<string>

the blob content as a string

示例
const blob = univerAPI.newBlob(); const data = await blob.getDataAsString('iso-8859-1'); console.log(data);

setBytes()

setBytes(bytes): FBlob

Sets the data stored in this blob.

参数

参数类型描述
bytesUint8Arraya byte array

返回

FBlob

the blob object

示例

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.

参数

参数类型描述
contentTypestringthe content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types

返回

FBlob

the blob object

示例

const blob = univerAPI.newBlob(); blob.setContentType('text/plain');

setDataFromString()

调用签名

setDataFromString(data): FBlob

Sets the data stored in this blob.

参数
参数类型描述
datastringblob data string
返回

FBlob

the blob object

示例
const blob = univerAPI.newBlob(); blob.setDataFromString('Hello, World!');

调用签名

setDataFromString(data, contentType?): FBlob

Sets the data stored in this blob.

参数
参数类型描述
datastringa string
contentType?stringthe content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
返回

FBlob

the blob object

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