package repository import ( "context" "io" "time" ) // FileStorageRepository 是一個通用的文件儲存操作接口,用於管理雲存儲或本地存儲中的對象文件。 type FileStorageRepository interface { // Download 下載指定路徑的對象並返回其內容 Download(ctx context.Context, objectPath string) ([]byte, error) // Move 將對象從一個路徑移動到另一個指定路徑 Move(ctx context.Context, objectPath string, destinationPath string) error // Delete 刪除指定路徑的對象 Delete(ctx context.Context, objectPath string) error // Exists 檢查指定路徑的對象是否存在 Exists(ctx context.Context, objectPath string) (bool, error) // DeleteDirectory 刪除指定路徑的文件夾及其內容 DeleteDirectory(ctx context.Context, directoryPath string) error // UploadWithTTL 從 io.Reader 上傳文件到指定路徑,並設置自訂過期時間 UploadWithTTL(ctx context.Context, content io.Reader, objectPath string, expires *time.Time) error // UploadFromData 直接從數據上傳文件到指定路徑,可指定 MIME 類型 UploadFromData(ctx context.Context, data []byte, objectPath string, contentType string) error // UploadFromPath 將本地文件從指定路徑上傳到對象存儲路徑 UploadFromPath(ctx context.Context, localFilePath string, objectPath string) error // GetPublicURL 獲取對象的完整公共 URL GetPublicURL(ctx context.Context, objectPath string) string }