优化文件上传

This commit is contained in:
不做码农 2023-06-30 09:42:35 +08:00
parent 4b1f79c1da
commit fb6f1bd496
2 changed files with 3 additions and 4 deletions

View File

@ -36,7 +36,7 @@
"DemoMode": false, // "DemoMode": false, //
"Upload": { "Upload": {
"uploadUrl": "http://localhost:8888", //访 "uploadUrl": "http://localhost:8888", //访
"localSavePath": "uploads", // wwwroot/uploads, saveType= 2 使, /home/resource) "localSavePath": "", // wwwroot
"maxSize": 15, // 15M "maxSize": 15, // 15M
"notAllowedExt": [ ".bat", ".exe", ".jar", ".js" ] "notAllowedExt": [ ".bat", ".exe", ".jar", ".js" ]
}, },

View File

@ -101,7 +101,7 @@ namespace ZR.Service.System
public string GetdirPath(string storePath = "", bool byTimeStore = true) public string GetdirPath(string storePath = "", bool byTimeStore = true)
{ {
DateTime date = DateTime.Now; DateTime date = DateTime.Now;
string timeDir = date.ToString("yyyyMMdd"); string timeDir = date.ToString("yyyy/MMdd");
if (!string.IsNullOrEmpty(storePath)) if (!string.IsNullOrEmpty(storePath))
{ {
@ -116,8 +116,7 @@ namespace ZR.Service.System
{ {
str = Guid.NewGuid().ToString(); str = Guid.NewGuid().ToString();
} }
MD5 md5 = MD5.Create(); return BitConverter.ToString(MD5.HashData(Encoding.Default.GetBytes(str)), 4, 8).Replace("-", "");
return BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(str)), 4, 8).Replace("-", "");
} }
public Task<long> InsertFile(SysFile file) public Task<long> InsertFile(SysFile file)