mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-09-04 23:29:00 +08:00
fix: standardize upload request path and handle null storage path in URL generation
This commit is contained in:
@@ -16,7 +16,7 @@ public static class ApplicationBuilderExtensions
|
|||||||
app.UseStaticFiles(new StaticFileOptions
|
app.UseStaticFiles(new StaticFileOptions
|
||||||
{
|
{
|
||||||
FileProvider = new PhysicalFileProvider(uploadsPath),
|
FileProvider = new PhysicalFileProvider(uploadsPath),
|
||||||
RequestPath = "/uploads"
|
RequestPath = "/Uploads"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public sealed class BackgroundTaskQueue : IBackgroundTaskQueue, IDisposable
|
|||||||
foreach (var picture in unfinishedPictures)
|
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);
|
string originalFilePath = Path.Combine(Directory.GetCurrentDirectory(), relativePath);
|
||||||
if (File.Exists(originalFilePath))
|
if (File.Exists(originalFilePath))
|
||||||
{
|
{
|
||||||
@@ -255,7 +255,7 @@ public sealed class BackgroundTaskQueue : IBackgroundTaskQueue, IDisposable
|
|||||||
{
|
{
|
||||||
// 本地存储缩略图
|
// 本地存储缩略图
|
||||||
relativeThumbnailPath =
|
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('\\', '/');
|
picture.ThumbnailPath = relativeThumbnailPath.Replace('\\', '/');
|
||||||
}
|
}
|
||||||
else if (picture.StorageType == StorageType.Telegram)
|
else if (picture.StorageType == StorageType.Telegram)
|
||||||
|
|||||||
@@ -30,8 +30,10 @@ public class LocalStorageProvider(IConfigService config) : IStorageProvider
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetUrl(string storagePath)
|
public string GetUrl(string? storagePath)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(storagePath))
|
||||||
|
return $"/images/unavailable.gif";
|
||||||
return $"{_serverUrl}{storagePath}";
|
return $"{_serverUrl}{storagePath}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user