export interface StorageObject { key: string; size: number; lastModified?: string | null; } export interface StorageListResult { items: StorageObject[]; nextCursor: string | null; } export interface UploadUrlResult { url: string; method: 'PUT'; expiresIn: number; headers?: Record; } export interface ThumbnailOptions { /** 目标宽(像素,≤2048);与 height 至少给一个,只给一边时按原图比例算另一边 */ width?: number; height?: number; /** cover = 裁切填满给定框(默认,适合方形头像/卡片);contain = 完整装下 */ fit?: 'cover' | 'contain'; /** 输出格式,默认 webp(体积最小、保留透明);要兼容极老环境用 jpeg */ format?: 'webp' | 'jpeg' | 'png'; /** 返回地址的有效期(秒) */ expiresIn?: number; /** 覆盖了同名原图时传 true 强制重新生成 */ refresh?: boolean; } export interface StorageClient { /** 服务端小文件直传(≤5MB) */ put(key: string, data: Uint8Array | ArrayBuffer | string | Blob, opts?: { contentType?: string; }): Promise<{ key: string; size: number; }>; /** 浏览器直传:返回预签名 PUT 地址(把它交给前端 fetch(url, { method:'PUT', body:file })) */ uploadUrl(key: string, opts?: { contentType?: string; size?: number; }): Promise; /** 读取对象内容(服务端) */ get(key: string): Promise; /** 临时访问地址(默认 10 分钟;可指定秒数、下载文件名)—— 用于 / 下载链接 */ url(key: string, opts?: { expiresIn?: number; downloadName?: string; }): Promise; /** * 缩略图地址(技术方案 37):按尺寸生成一次并缓存在存储里,之后都是直接的临时地址。 * 列表页 / 头像 / 相册**一律用它**,别挂原图——用户手机拍的照片动辄几 MB。 * ```tsx * * ``` * 只有平台托管驱动会真缩放;memory / edgeone / byo 返回原图地址(页面照常显示,只是没变小)。 */ thumbnail(key: string, opts?: ThumbnailOptions): Promise; head(key: string): Promise; delete(key: string): Promise; list(prefix?: string, opts?: { cursor?: string | null; limit?: number; }): Promise; } export declare function getStorage(): StorageClient; export declare const storage: StorageClient;