feat(StorageService, PictureController): refactor storage service methods to use unified ExecuteAsync pattern for file operations

This commit is contained in:
shiyu
2025-05-28 18:47:57 +08:00
parent 672e0611fa
commit f52507b129
5 changed files with 43 additions and 76 deletions

View File

@@ -225,7 +225,8 @@ public sealed class BackgroundTaskQueue : IBackgroundTaskQueue, IDisposable
{
// 非本地存储需要先下载文件
await UpdatePictureStatus(task.PictureId, ProcessingStatus.Processing, 15);
localFilePath = await storageService.DownloadFileAsync(picture.StorageType, picture.Path);
localFilePath = await storageService.ExecuteAsync(picture.StorageType,
provider => provider.DownloadFileAsync(picture.Path));
isTempFile = true;
}
@@ -259,11 +260,9 @@ public sealed class BackgroundTaskQueue : IBackgroundTaskQueue, IDisposable
var thumbnailContentType = "image/webp";
// 上传缩略图并获取存储路径或元数据
string thumbnailStoragePath = await storageService.SaveAsync(
string thumbnailStoragePath = await storageService.ExecuteAsync(
picture.StorageType,
thumbnailFileStream,
thumbnailFileName,
thumbnailContentType);
provider => provider.SaveAsync(thumbnailFileStream, thumbnailFileName, thumbnailContentType));
// 将路径或元数据存储到ThumbnailPath
picture.ThumbnailPath = thumbnailStoragePath;