修改文件存储

This commit is contained in:
不做码农
2022-06-09 14:59:28 +08:00
6 changed files with 30 additions and 22 deletions

View File

@@ -110,13 +110,15 @@ namespace ZR.Admin.WebApi.Controllers
switch (storeType)
{
case StoreType.LOCAL:
string savePath = AppSettings.App(new string[] { "Upload", "localSavePath" });
if (savePath.IsEmpty())
string savePath = Path.Combine(WebHostEnvironment.WebRootPath);
if (fileDir.IsEmpty())
{
savePath = Path.Combine(WebHostEnvironment.WebRootPath, "uploads");
fileDir = AppSettings.App(new string[] { "Upload", "localSavePath" });
}
file = await SysFileService.SaveFileToLocal(savePath, fileName, fileDir, HttpContext.GetName(), formFile);
break;
case StoreType.REMOTE:
break;
case StoreType.ALIYUN:
if ((fileSize / 1024) > MaxContentLength)
{

View File

@@ -131,7 +131,7 @@ namespace ZR.Admin.WebApi.Controllers.System
LoginUser loginUser = Framework.JwtUtil.GetLoginUser(HttpContext);
if (formFile == null) throw new CustomException("请选择文件");
SysFile file = await FileService.SaveFileToLocal(hostEnvironment.WebRootPath, "", "", HttpContext.GetName(), formFile);
SysFile file = await FileService.SaveFileToLocal(hostEnvironment.WebRootPath, "", "avatar", HttpContext.GetName(), formFile);
UserService.UpdatePhoto(new SysUser() { Avatar = file.AccessUrl, UserId = loginUser.UserId });
return SUCCESS(new { imgUrl = file.AccessUrl });