FBlob
Access
Access through:
Setup
Register @univerjs/core or a preset that includes it. In plugin mode, import @univerjs/core/facade. Additional methods below require their listed plugin packages. See Facade setup.
@univerjs/core
FBlob.copyBlob
Returns a copy of this blob.
copyBlob(): FBlobReturns
a new blob by copying the current blob
Examples
const blob = univerAPI.newBlob()const newBlob = blob.copyBlob()console.log(newBlob)Types: FBlob
Package: @univerjs/core · Type definitions
FBlob.getAs
Return the data inside this object as a blob converted to the specified content type.
getAs(contentType: string): FBlobParameters
contentType— Required. 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
Examples
const blob = univerAPI.newBlob()const newBlob = blob.getAs('text/plain')console.log(newBlob)Types: FBlob
Package: @univerjs/core · Type definitions
FBlob.getBytes
Gets the data stored in this blob.
getBytes(): Promise<Uint8Array>Returns
the blob content as a byte array
Examples
const blob = univerAPI.newBlob()const bytes = await blob.getBytes()console.log(bytes)Types: Uint8Array · Promise
Package: @univerjs/core · Type definitions
FBlob.getContentType
Gets the content type of the data stored in this blob.
getContentType(): string | undefinedReturns
the content type
Examples
const blob = univerAPI.newBlob()const contentType = blob.getContentType()console.log(contentType)Package: @univerjs/core · Type definitions
FBlob.getDataAsString
Get the blob as a string.
getDataAsString(): Promise<string>getDataAsString(charset?: string): Promise<string>Parameters
charset— Optional. the charset
Returns
the blob content as a string
Examples
const blob = univerAPI.newBlob()const data = await blob.getDataAsString()console.log(data)const blob = univerAPI.newBlob()const data = await blob.getDataAsString('iso-8859-1')console.log(data)Types: Promise
Package: @univerjs/core · Type definitions
FBlob.setBytes
Sets the data stored in this blob.
setBytes(bytes: Uint8Array): FBlobParameters
bytes— Required. a byte array
Returns
the blob object
Examples
const blob = univerAPI.newBlob()const bytes = new Uint8Array(10)blob.setBytes(bytes)Types: FBlob · Uint8Array
Package: @univerjs/core · Type definitions
FBlob.setContentType
Sets the content type of the data stored in this blob.
setContentType(contentType: string): FBlobParameters
contentType— Required. the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
Returns
the blob object
Examples
const blob = univerAPI.newBlob()blob.setContentType('text/plain')Types: FBlob
Package: @univerjs/core · Type definitions
FBlob.setDataFromString
Sets the data stored in this blob.
setDataFromString(data: string): FBlobsetDataFromString(data: string, contentType?: string): FBlobParameters
data— Required. a stringcontentType— Optional. the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
Returns
the blob object
Examples
const blob = univerAPI.newBlob()blob.setDataFromString('Hello, World!')const blob = univerAPI.newBlob()blob.setDataFromString('Hello, World!', 'text/plain')Types: FBlob
Package: @univerjs/core · Type definitions
How is this guide?