FBlob

GitHubEdit on GitHub
packages@univerjs/core

APIs

copyBlob

Returns a copy of this blob.

Signature

copyBlob(): FBlob

Returns

  • (FBlob) — a new blob by copying the current blob

Examples

const blob = univerAPI.newBlob()
const newBlob = blob.copyBlob()
console.log(newBlob)

getAs

Return the data inside this object as a blob converted to the specified content type.

Signature

getAs(contentType: string): FBlob

Parameters

Returns

  • (FBlob) — 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)

getBytes

Gets the data stored in this blob.

Signature

getBytes(): Promise<Uint8Array>

Returns

  • (Promise<Uint8Array>) — the blob content as a byte array

Examples

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

getContentType

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

Signature

getContentType(): string | undefined

Returns

  • (string | undefined) — the content type

Examples

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

getDataAsString

Signature

getDataAsString(charset?: string): Promise<string>

setBytes

Sets the data stored in this blob.

Signature

setBytes(bytes: Uint8Array): FBlob

Parameters

  • bytes (Uint8Array) — a byte array

Returns

  • (FBlob) — the blob object

Examples

const blob = univerAPI.newBlob()
const bytes = new Uint8Array(10)
blob.setBytes(bytes)

setContentType

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

Signature

setContentType(contentType: string): FBlob

Parameters

Returns

  • (FBlob) — the blob object

Examples

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

setDataFromString

Signature

setDataFromString(data: string, contentType?: string): FBlob