diff --git a/Extensions/ApplicationBuilderExtensions.cs b/Extensions/ApplicationBuilderExtensions.cs index 237593e..8f85cba 100644 --- a/Extensions/ApplicationBuilderExtensions.cs +++ b/Extensions/ApplicationBuilderExtensions.cs @@ -16,7 +16,7 @@ public static class ApplicationBuilderExtensions app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(uploadsPath), - RequestPath = "/uploads" + RequestPath = "/Uploads" }); } diff --git a/Services/BackgroundTaskQueue.cs b/Services/BackgroundTaskQueue.cs index 2825f12..9622506 100644 --- a/Services/BackgroundTaskQueue.cs +++ b/Services/BackgroundTaskQueue.cs @@ -122,7 +122,7 @@ public sealed class BackgroundTaskQueue : IBackgroundTaskQueue, IDisposable foreach (var picture in unfinishedPictures) { // 构建原始文件路径 - string relativePath = picture.Path.TrimStart('/').Replace("uploads", "Uploads"); + string relativePath = picture.Path.TrimStart('/'); string originalFilePath = Path.Combine(Directory.GetCurrentDirectory(), relativePath); if (File.Exists(originalFilePath)) { @@ -255,7 +255,7 @@ public sealed class BackgroundTaskQueue : IBackgroundTaskQueue, IDisposable { // 本地存储缩略图 relativeThumbnailPath = - $"/uploads/{Path.GetRelativePath("Uploads", Path.GetDirectoryName(thumbnailPath)!)}/{Path.GetFileName(thumbnailPath)}"; + $"/Uploads/{Path.GetRelativePath("Uploads", Path.GetDirectoryName(thumbnailPath)!)}/{Path.GetFileName(thumbnailPath)}"; picture.ThumbnailPath = relativeThumbnailPath.Replace('\\', '/'); } else if (picture.StorageType == StorageType.Telegram) diff --git a/Services/StorageProvider/LocalStorageProvider.cs b/Services/StorageProvider/LocalStorageProvider.cs index 34913ca..4d4852a 100644 --- a/Services/StorageProvider/LocalStorageProvider.cs +++ b/Services/StorageProvider/LocalStorageProvider.cs @@ -30,8 +30,10 @@ public class LocalStorageProvider(IConfigService config) : IStorageProvider return Task.CompletedTask; } - public string GetUrl(string storagePath) + public string GetUrl(string? storagePath) { + if (string.IsNullOrEmpty(storagePath)) + return $"/images/unavailable.gif"; return $"{_serverUrl}{storagePath}"; }