From 4211b72041ffd68d5c97f24041eb6b3e7dfc20e9 Mon Sep 17 00:00:00 2001 From: wanghu Date: Wed, 9 Sep 2026 16:04:46 +0800 Subject: [PATCH] Config.FilePath --- src/YhCore.Service/Impl/FileService.cs | 10 +++++----- src/YhCore.WebApi/appsettings.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/YhCore.Service/Impl/FileService.cs b/src/YhCore.Service/Impl/FileService.cs index 261aaa5..79d2cd6 100644 --- a/src/YhCore.Service/Impl/FileService.cs +++ b/src/YhCore.Service/Impl/FileService.cs @@ -71,7 +71,7 @@ namespace YhCore.Service.Impl if (appType.ToLower() == "noticemsg") appType = "notice"; string dtStr = DateTime.Now.ToString("yyyyMMdd"); string physicalDir = Path.Combine(StorageRoot(), appType, dtStr); - string outFilePath = "/upload/" + appType + "/" + dtStr + "/"; + string outFilePath = Config.FilePath + appType + "/" + dtStr + "/"; if (!Directory.Exists(physicalDir)) Directory.CreateDirectory(physicalDir); @@ -109,7 +109,7 @@ namespace YhCore.Service.Impl if (appType.ToLower() == "noticemsg") appType = "notice"; string dtStr = DateTime.Now.ToString("yyyyMMdd"); string physicalDir = Path.Combine(StorageRoot(), appType, dtStr); - string outFilePath = "/upload/" + appType + "/" + dtStr + "/"; + string outFilePath = Config.FilePath + appType + "/" + dtStr + "/"; if (!Directory.Exists(physicalDir)) Directory.CreateDirectory(physicalDir); @@ -169,7 +169,7 @@ namespace YhCore.Service.Impl if (appType.ToLower() == "noticemsg") appType = "notice"; string dtStr = DateTime.Now.ToString("yyyyMMdd"); string physicalDir = Path.Combine(StorageRoot(), appType, dtStr); - string outFilePath = "/upload/" + appType + "/" + dtStr + "/"; + string outFilePath = Config.FilePath+ appType + "/" + dtStr + "/"; if (!Directory.Exists(physicalDir)) Directory.CreateDirectory(physicalDir); @@ -216,7 +216,7 @@ namespace YhCore.Service.Impl // 相对路径如 /upload/docprint/20260101/{guid}.jpg → Config.FilePath + 子路径 var relative = fileUrl.TrimStart('/'); - const string prefix = "upload/"; + string prefix = Config.FilePath; if (relative.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) relative = relative.Substring(prefix.Length); @@ -229,7 +229,7 @@ namespace YhCore.Service.Impl if (!string.IsNullOrEmpty(Config.FilePath)) return Config.FilePath; - return Path.Combine(AppContext.BaseDirectory, "upload"); + return Path.Combine(AppContext.BaseDirectory,Config.FilePath); } } } diff --git a/src/YhCore.WebApi/appsettings.json b/src/YhCore.WebApi/appsettings.json index b3d077a..0bca973 100644 --- a/src/YhCore.WebApi/appsettings.json +++ b/src/YhCore.WebApi/appsettings.json @@ -10,7 +10,7 @@ "Redis": { "ConnectionString": "localhost:6379,defaultDatabase=0" }, - "FILE_PATH": "upload", + "FILE_PATH": "", "FILE_WEB_PATH": "", "wkhtmltopdf_path": "", "yh": {