Skip to content

BlobResponse

DTO returned by RequestBuilder.fetchBlob. Pairs a binary payload with the resolved filename, ready to be handed to a download helper.

Importing

ts
import { BlobResponse } from '@basmilius/http-client';

Constructor

ts
new BlobResponse(blob: Blob, name: string)
ArgumentTypeDescription
blobBlobThe binary payload from the API.
namestringThe filename suggested by the API.

Properties

  • blobBlob. Read-only. The binary payload.
  • namestring. Read-only. Filename derived from the Content-Disposition header, or a download-yyyy-MM-dd HH-mm-ss timestamp fallback.

Methods

BlobResponse is decorated with @dto and therefore exposes clone(), fill() and toJSON() from the DTO machinery.

Example

ts
import { downloadBlob } from '@basmilius/utils';

const result = await this
    .request('/exports/users.csv')
    .method('get')
    .bearerToken()
    .fetchBlob();

downloadBlob(result.blob, result.name);

See also