feat(storage): storage port and minio adapter with forbid-overwrite semantics
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
// packages/storage/src/port.ts —— 存储端口(唯一抽象):生产 OSS 适配器(P5/G1)
|
||||
// 与本包 MinIO 适配器实现同一接口;api(presign/verify)与 worker(variants put/get)
|
||||
// 只依赖此端口,不感知后端差异。
|
||||
export interface UploadCredential {
|
||||
mode: 'presigned';
|
||||
url: string;
|
||||
method: 'PUT';
|
||||
headers: Record<string, string>;
|
||||
expiresAt: string; // ISO
|
||||
}
|
||||
export interface StoragePort {
|
||||
presignPut(objectKey: string, bytes: number, contentType: string, ttlSeconds: number): Promise<UploadCredential>;
|
||||
presignGet(objectKey: string, ttlSeconds: number): Promise<string>;
|
||||
head(objectKey: string): Promise<{ bytes: number; etag: string } | null>;
|
||||
getStream(objectKey: string): Promise<NodeJS.ReadableStream>;
|
||||
put(objectKey: string, body: Buffer, contentType: string): Promise<{ etag: string }>;
|
||||
/** 复制到正式键;目标已存在时校验一致性并幂等返回(禁止覆盖语义)。 */
|
||||
copyIfAbsent(src: string, dest: string, expectedBytes: number): Promise<{ created: boolean; etag: string }>;
|
||||
}
|
||||
Reference in New Issue
Block a user