类: FBlob
继承
FBase
方法
copyBlob()
copyBlob(): FBlob
Returns a copy of this blob.
返回
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.
参数
参数 | 类型 | 描述 |
---|---|---|
contentType | string | the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types |
返回
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 ? | string | the 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.
参数
参数 | 类型 | 描述 |
---|---|---|
bytes | Uint8Array | a byte array |
返回
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.
参数
参数 | 类型 | 描述 |
---|---|---|
contentType | string | the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types |
返回
the blob object
示例
const blob = univerAPI.newBlob();
blob.setContentType('text/plain');
setDataFromString()
调用签名
setDataFromString(data): FBlob
Sets the data stored in this blob.
参数
参数 | 类型 | 描述 |
---|---|---|
data | string | blob data string |
返回
the blob object
示例
const blob = univerAPI.newBlob();
blob.setDataFromString('Hello, World!');
调用签名
setDataFromString(data, contentType?): FBlob
Sets the data stored in this blob.
参数
参数 | 类型 | 描述 |
---|---|---|
data | string | a string |
contentType ? | string | the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types |
返回
the blob object
示例
const blob = univerAPI.newBlob();
blob.setDataFromString('Hello, World!', 'text/plain');