import type { EponymeMediaItem, EponymeMediaMeta, EponymeStorageDriver, EponymeStorageObject } from '../../types/storage.js'; export interface EponymeMediaSettings { prefix: string; maxSize: number; accept: string[]; /** Reads go through the application and ask for `media.read`, instead of being public and cacheable. */ private?: boolean; } /** * Keys are validated here as well as in the driver: a key arrives from the browser on every media route, * and a route that hands an unchecked one to a driver is trusting the client to stay inside the prefix. */ export declare function assertEponymeMediaKey(key: unknown, settings: EponymeMediaSettings): string; export declare function isEponymeActiveMedia(key: string, contentType?: string): boolean; export declare function assertEponymeUpload(contentType: string, size: number, settings: EponymeMediaSettings, fileName?: string): void; /** * Stops a body at `limit` bytes, whatever `Content-Length` announced. The driver reads a stream until it * ends and counts nothing itself, so this is the only place the transfer is actually bounded. */ export declare function limitEponymeStream(body: ReadableStream, limit: number): ReadableStream; export declare function formatBytes(bytes: number): string; /** * A stored key derived from the uploaded name: dated folders so a bucket stays browsable, a slug so it * stays readable, and a random suffix so two uploads of `photo.jpg` never collide - an overwrite would * silently change an image already published somewhere else. */ export declare function buildEponymeMediaKey(fileName: string, settings: EponymeMediaSettings): string; /** * The shape `buildEponymeMediaKey()` writes: dated folders, a slug, a random suffix. The upload route * accepts a key from the client, so it accepts only one it could have generated - a chosen key such as * `uploads/logo.png` would name an object someone else already published. */ export declare function assertEponymeReservedKey(key: string, settings: EponymeMediaSettings): void; /** Where Eponyme reads an object back when the driver has no address that lasts. */ export declare function eponymeRawUrl(key: string): string; /** An address that will still resolve in a year, which is the only kind worth saving into an entry. */ export declare function eponymePublicUrl(driver: EponymeStorageDriver, key: string, settings: EponymeMediaSettings): Promise; /** The same decision for a whole page of a listing, taken once. */ export declare function toEponymeMediaItems(driver: EponymeStorageDriver, objects: EponymeStorageObject[], settings: EponymeMediaSettings): Promise; export declare const EPONYME_MEDIA_META_SUFFIX = ".eponyme.json"; export declare function eponymeMediaMetaKey(key: string): string; export declare function isEponymeMediaMetaKey(key: string): boolean; /** * Checks what an editor sends before it is written next to an object. Strict, since the result is served * to every later picker: a wrong type is refused rather than coerced. */ export declare function parseEponymeMediaMeta(input: unknown): EponymeMediaMeta; /** The sidecar of `key`, or `undefined` when there is none or it cannot be read: it is a convenience. */ export declare function readEponymeMediaMeta(driver: EponymeStorageDriver, key: string): Promise; export declare function writeEponymeMediaMeta(driver: EponymeStorageDriver, key: string, meta: EponymeMediaMeta): Promise; /** * Read from the key rather than asked of the provider: a listing returns hundreds of objects, and a `stat` * each would be hundreds of round trips for a label. */ export declare function guessContentType(key: string): string;