# ckbox/utils

module

<a id="functions">

## Functions

<a id="function-blurHashToDataUrl">

### `blurHashToDataUrl( hash? ) → string | undefined` _(internal)_

Generates an image data URL from its `blurhash` representation.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ckbox/src/utils.ts#L90)

#### Parameters

* `hash?: string`

#### Returns

* `string | undefined`

<a id="function-convertMimeTypeToExtension">

### `convertMimeTypeToExtension( mimeType ) → string` _(internal)_

Returns an extension a typical file in the specified `mimeType` format would have.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ckbox/src/utils.ts#L216)

#### Parameters

* `mimeType: string`

#### Returns

* `string`

<a id="function-getContentTypeOfUrl">

### `getContentTypeOfUrl( url, options = { options.signal } ) → Promise<string>` _(internal)_

Tries to fetch the given `url` and returns 'content-type' of the response.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ckbox/src/utils.ts#L225)

#### Parameters

* `url: string`

* `options: object`

  Properties

  * `options.signal: AbortSignal`

#### Returns

* `Promise<string>`

<a id="function-getFileExtension">

### `getFileExtension( file ) → string` _(internal)_

Returns an extension from the given value.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ckbox/src/utils.ts#L248)

#### Parameters

* `file: File`

#### Returns

* `string`

<a id="function-getImageUrls">

### `getImageUrls( imageUrls ) → object` _(internal)_

Converts image source set provided by the CKBox into an object containing:

* responsive URLs for the "webp" image format,
* one fallback URL for browsers that do not support the "webp" format.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ckbox/src/utils.ts#L22)

#### Parameters

* `imageUrls: CKBoxImageUrls`

#### Returns

* `object`

<a id="function-getWorkspaceId">

### `getWorkspaceId( token, defaultWorkspaceId? ) → string | null` _(internal)_

Returns a workspace id to use for communication with the CKBox service.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ckbox/src/utils.ts#L63)

#### Parameters

* `token: InitializedToken`

* `defaultWorkspaceId?: string`

  The default workspace to use taken from editor config.

#### Returns

* `string | null`

<a id="function-sendHttpRequest">

### `sendHttpRequest( options = { options.authorization, options.data?, options.method?, options.onUploadProgress?, options.signal, options.url } ) → Promise<any>` _(internal)_

Sends the HTTP request.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ckbox/src/utils.ts#L133)

#### Parameters

* `options: object`

  Configuration options

  Properties

  * `options.authorization: string`

    The authorization token for the request.

  * `options.data?: FormData | null`

    Additional data to send.

  * `options.method?: 'POST' | 'GET'`

    The HTTP method (default: 'GET').

    Defaults to `'GET'`

  * `options.onUploadProgress?: ( evt: ProgressEvent ) => void`

    A callback informing about the upload progress.

  * `options.signal: AbortSignal`

    The AbortSignal to abort the request when needed.

  * `options.url: URL`

    The URL where the request will be sent.

#### Returns

* `Promise<any>`

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
