# FBlob

> Language fallback: requested `zh-CN`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/zh-CN/reference/facade/blob](https://docs.univer.ai/zh-CN/reference/facade/blob)

- Agent Markdown: [https://docs.univer.ai/zh-CN/reference/facade/blob.md](https://docs.univer.ai/zh-CN/reference/facade/blob.md)

- Requested language: `zh-CN`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [facade/blob.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/facade/blob.mdx)

---

## Access

Access through:

* [`FUniver.newBlob()`](https://docs.univer.ai/zh-CN/reference/facade/univer.md#newblob)

## Setup

Register [`@univerjs/core`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/core.md) or a preset that includes it. In plugin mode, import `@univerjs/core/facade`. Additional methods below require their listed plugin packages. See [Facade setup](https://docs.univer.ai/zh-CN/guides/sheets/getting-started/facade.md).

## `@univerjs/core`

### `FBlob.copyBlob`

Returns a copy of this blob.

```typescript
copyBlob(): FBlob
```

**Returns**

a new blob by copying the current blob

**Examples**

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

**Types:** [`FBlob`](https://docs.univer.ai/zh-CN/reference/facade/blob.md)

**Package:** [`@univerjs/core`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/core.md) · [Type definitions](https://unpkg.com/@univerjs/core@1.0.0-rc.0/lib/types/facade/f-blob.d.ts)

### `FBlob.getAs`

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

```typescript
getAs(contentType: string): FBlob
```

**Parameters**

* `contentType` — Required. the content type refer to [https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME\_types/Common\_types](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**

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

**Types:** [`FBlob`](https://docs.univer.ai/zh-CN/reference/facade/blob.md)

**Package:** [`@univerjs/core`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/core.md) · [Type definitions](https://unpkg.com/@univerjs/core@1.0.0-rc.0/lib/types/facade/f-blob.d.ts)

### `FBlob.getBytes`

Gets the data stored in this blob.

```typescript
getBytes(): Promise<Uint8Array>
```

**Returns**

the blob content as a byte array

**Examples**

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

**Types:** [`Uint8Array`](https://unpkg.com/@typescript/typescript-darwin-arm64@7.0.2/lib/lib.es5.d.ts) · [`Promise`](https://unpkg.com/@typescript/typescript-darwin-arm64@7.0.2/lib/lib.es5.d.ts)

**Package:** [`@univerjs/core`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/core.md) · [Type definitions](https://unpkg.com/@univerjs/core@1.0.0-rc.0/lib/types/facade/f-blob.d.ts)

### `FBlob.getContentType`

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

```typescript
getContentType(): string | undefined
```

**Returns**

the content type

**Examples**

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

**Package:** [`@univerjs/core`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/core.md) · [Type definitions](https://unpkg.com/@univerjs/core@1.0.0-rc.0/lib/types/facade/f-blob.d.ts)

### `FBlob.getDataAsString`

Get the blob as a string.

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

**Parameters**

* `charset` — Optional. the charset

**Returns**

the blob content as a string

**Examples**

```ts
const blob = univerAPI.newBlob()
const data = await blob.getDataAsString()
console.log(data)
```

```ts
const blob = univerAPI.newBlob()
const data = await blob.getDataAsString('iso-8859-1')
console.log(data)
```

**Types:** [`Promise`](https://unpkg.com/@typescript/typescript-darwin-arm64@7.0.2/lib/lib.es5.d.ts)

**Package:** [`@univerjs/core`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/core.md) · [Type definitions](https://unpkg.com/@univerjs/core@1.0.0-rc.0/lib/types/facade/f-blob.d.ts)

### `FBlob.setBytes`

Sets the data stored in this blob.

```typescript
setBytes(bytes: Uint8Array): FBlob
```

**Parameters**

* `bytes` — Required. a byte array

**Returns**

the blob object

**Examples**

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

**Types:** [`FBlob`](https://docs.univer.ai/zh-CN/reference/facade/blob.md) · [`Uint8Array`](https://unpkg.com/@typescript/typescript-darwin-arm64@7.0.2/lib/lib.es5.d.ts)

**Package:** [`@univerjs/core`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/core.md) · [Type definitions](https://unpkg.com/@univerjs/core@1.0.0-rc.0/lib/types/facade/f-blob.d.ts)

### `FBlob.setContentType`

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

```typescript
setContentType(contentType: string): FBlob
```

**Parameters**

* `contentType` — Required. the content type refer to [https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME\_types/Common\_types](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types)

**Returns**

the blob object

**Examples**

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

**Types:** [`FBlob`](https://docs.univer.ai/zh-CN/reference/facade/blob.md)

**Package:** [`@univerjs/core`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/core.md) · [Type definitions](https://unpkg.com/@univerjs/core@1.0.0-rc.0/lib/types/facade/f-blob.d.ts)

### `FBlob.setDataFromString`

Sets the data stored in this blob.

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

**Parameters**

* `data` — Required. a string
* `contentType` — Optional. the content type refer to [https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME\_types/Common\_types](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types)

**Returns**

the blob object

**Examples**

```ts
const blob = univerAPI.newBlob()
blob.setDataFromString('Hello, World!')
```

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

**Types:** [`FBlob`](https://docs.univer.ai/zh-CN/reference/facade/blob.md)

**Package:** [`@univerjs/core`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/core.md) · [Type definitions](https://unpkg.com/@univerjs/core@1.0.0-rc.0/lib/types/facade/f-blob.d.ts)
