feat(StorageConfig): enhance storage settings UI with separate configurations for logged-in and anonymous users

This commit is contained in:
ShiYu
2025-05-24 00:35:13 +08:00
parent 6da267a566
commit 5c5b63e82f
2 changed files with 244 additions and 158 deletions

View File

@@ -441,15 +441,22 @@ public class PictureService(
ImageFormat convertToFormat = ImageFormat.Original,
int quality = 95)
{
// 如果未指定存储类型,则从配置中获取默认存储类型
if (storageType == null)
StorageType GetConfigStorageType(string configKey)
{
var defaultStorageTypeStr = configuration["Storage:DefaultStorage"];
if (string.IsNullOrEmpty(defaultStorageTypeStr) || !Enum.TryParse<StorageType>(defaultStorageTypeStr, out var defaultStorageType))
{
defaultStorageType = StorageType.Local; // 如果配置中没有或解析失败,使用本地存储作为默认
}
storageType = defaultStorageType;
string? configValue = configuration[configKey];
return !string.IsNullOrEmpty(configValue) &&
Enum.TryParse<StorageType>(configValue, out var configStorageType)
? configStorageType
: StorageType.Local;
}
if (userId == null)
{
storageType = GetConfigStorageType("Storage:AnonymousDefaultStorage");
}
else if (storageType == null)
{
storageType = GetConfigStorageType("Storage:DefaultStorage");
}
string originalFileName = fileName;