修改文件存储
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
},
|
||||
"DemoMode": false, //是否演示模式
|
||||
"Upload": {
|
||||
"UploadUrl": "http://localhost:8888",
|
||||
"localSavePath": "" //本地上传文件存储目录/home/website/uploads
|
||||
"UploadUrl": "http://localhost:8888", //本地存储资源访问路径
|
||||
"localSavePath": "uploads" //本地上传默认文件存储目录 wwwroot/uploads
|
||||
},
|
||||
//阿里云存储配置
|
||||
"ALIYUN_OSS": {
|
||||
|
||||
Reference in New Issue
Block a user