bknd
Version:
Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.
42 lines (41 loc) • 2.12 kB
TypeScript
import type { FileListObject } from "../../media/storage/Storage";
import { type BaseModuleApiOptions, type FetchPromise, type ResponseObject, ModuleApi, type PrimaryFieldType, type TInput } from "../../modules/ModuleApi";
import type { ApiFetcher } from "../../Api";
import type { DB, FileUploadedEventData } from "../..";
export type MediaApiOptions = BaseModuleApiOptions & {
upload_fetcher: ApiFetcher;
init?: RequestInit;
};
export declare class MediaApi extends ModuleApi<MediaApiOptions> {
protected getDefaultOptions(): Partial<MediaApiOptions>;
listFiles(): FetchPromise<ResponseObject<FileListObject[], FileListObject[]>>;
getFile(filename: string): FetchPromise<ResponseObject<ReadableStream<Uint8Array<ArrayBufferLike>>, ReadableStream<Uint8Array<ArrayBufferLike>>>>;
getFileStream(filename: string): Promise<ReadableStream<Uint8Array>>;
download(filename: string): Promise<File>;
getFileUploadUrl(file?: {
path: string;
}): string;
getEntityUploadUrl(entity: string, id: PrimaryFieldType, field: string): string;
getUploadHeaders(): Headers;
protected uploadFile<T extends FileUploadedEventData>(body: BodyInit, opts?: {
filename?: string;
path?: TInput;
_init?: Omit<RequestInit, "body">;
query?: Record<string, any>;
}): FetchPromise<ResponseObject<T>>;
upload<T extends FileUploadedEventData>(item: Request | Response | string | File | Blob | ReadableStream | Buffer<ArrayBufferLike>, opts?: {
filename?: string;
_init?: Omit<RequestInit, "body">;
path?: TInput;
fetcher?: ApiFetcher;
query?: Record<string, any>;
}): Promise<ResponseObject<T>>;
uploadToEntity(entity: string, id: PrimaryFieldType, field: string, item: Request | Response | string | File | ReadableStream | Buffer<ArrayBufferLike>, opts?: {
_init?: Omit<RequestInit, "body">;
fetcher?: typeof fetch;
overwrite?: boolean;
}): Promise<ResponseObject<FileUploadedEventData & {
result: DB["media"];
}>>;
deleteFile(filename: string): FetchPromise<any>;
}