cloudflare
Version:
The official TypeScript library for the Cloudflare API
52 lines (46 loc) • 1.57 kB
text/typescript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../../core/resource';
import { APIPromise } from '../../../core/api-promise';
import { buildHeaders } from '../../../internal/headers';
import { RequestOptions } from '../../../internal/request-options';
import { path } from '../../../internal/utils/path';
export class BaseBlobs extends APIResource {
static override readonly _key: readonly ['images', 'v1', 'blobs'] = Object.freeze([
'images',
'v1',
'blobs',
] as const);
/**
* Download an image from CF Images. For most images this will be the originally
* uploaded file. For larger images it can be a near-lossless version of the
* original.
*
* @example
* ```ts
* const blob = await client.images.v1.blobs.get('image_id', {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
*
* const content = await blob.blob();
* console.log(content);
* ```
*/
get(imageID: string, params: BlobGetParams, options?: RequestOptions): APIPromise<Response> {
const { account_id } = params;
return this._client.get(path`/accounts/${account_id}/images/v1/${imageID}/blob`, {
...options,
headers: buildHeaders([{ Accept: 'image/*' }, options?.headers]),
__binaryResponse: true,
});
}
}
export class Blobs extends BaseBlobs {}
export interface BlobGetParams {
/**
* Account identifier tag.
*/
account_id: string;
}
export declare namespace Blobs {
export { type BlobGetParams as BlobGetParams };
}