UNPKG

@uploadx/core

Version:
56 lines (55 loc) 1.32 kB
import { Logger } from '../utils'; /** @experimental */ export interface UploadListEntry { /** upload id */ id: string; createdAt: string | Date | number; expiredAt?: string | Date | number; modifiedAt?: string | Date | number; } /** @experimental */ export interface UploadList { items: UploadListEntry[]; prefix?: string; } export interface MetaStorageOptions { prefix?: string; suffix?: string; logger?: Logger; } /** * Stores upload metadata */ export declare class MetaStorage<T> { prefix: string; suffix: string; logger: Logger; constructor(config?: MetaStorageOptions); /** * Saves upload metadata */ save(id: string, file: T): Promise<T>; /** * Deletes an upload metadata */ delete(id: string): Promise<void>; /** * Retrieves upload metadata */ get(id: string): Promise<T>; /** * Mark upload active */ touch(id: string, file: T): Promise<T>; /** * Retrieves a list of uploads whose names begin with the prefix * @experimental */ list(prefix?: string): Promise<UploadList>; getMetaName(id: string): string; getIdFromMetaName(name: string): string; } /** * @deprecated Use MetaStorage.suffix instead */ export declare const METAFILE_EXTNAME = ".META";