package storage import ( "context" "io" ) // StorageService 存储服务接口 type StorageService interface { // 文件上传 UploadFile(ctx context.Context, fileBytes []byte, fileName string) (*UploadResult, error) UploadFromReader(ctx context.Context, reader io.Reader, fileName string, size int64) (*UploadResult, error) // 生成上传凭证 GenerateUploadToken(ctx context.Context, key string) (string, error) // 文件访问 GetFileURL(ctx context.Context, key string) string GetPrivateFileURL(ctx context.Context, key string, expires int64) (string, error) // 文件管理 DeleteFile(ctx context.Context, key string) error FileExists(ctx context.Context, key string) (bool, error) GetFileInfo(ctx context.Context, key string) (*FileInfo, error) } // UploadResult 文件上传结果 type UploadResult struct { URL string `json:"url"` // 文件访问URL Key string `json:"key"` // 存储键名 Size int64 `json:"size"` // 文件大小 MimeType string `json:"mime_type"` // 文件类型 Hash string `json:"hash"` // 文件哈希值 } // FileInfo 文件信息 type FileInfo struct { Key string `json:"key"` // 存储键名 Size int64 `json:"size"` // 文件大小 MimeType string `json:"mime_type"` // 文件类型 Hash string `json:"hash"` // 文件哈希值 PutTime int64 `json:"put_time"` // 上传时间戳 }