Browse Source

fix: removed IFormFile to StaticFilesController action

pull/297/head
cKey 4 years ago
parent
commit
b517f2c9d4
  1. 1
      aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN/Abp/OssManagement/Localization/Resources/en.json
  2. 1
      aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN/Abp/OssManagement/Localization/Resources/zh-Hans.json
  3. 13
      aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi/LINGYUN/Abp/OssManagement/StaticFilesController.cs

1
aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN/Abp/OssManagement/Localization/Resources/en.json

@ -15,6 +15,7 @@
"Permission:Delete": "Delete",
"Permission:Upload": "Upload",
"Permission:Download": "Download",
"FileNotBeNullOrEmpty": "Upload file not be null!",
"FileNotFound": "The specified file does not exist!",
"PathNotFound": "The specified directory does not exist!",
"FilePathNotFound": "The file or directory does not exist!",

1
aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN/Abp/OssManagement/Localization/Resources/zh-Hans.json

@ -15,6 +15,7 @@
"Permission:Delete": "删除",
"Permission:Upload": "上传",
"Permission:Download": "下载",
"FileNotBeNullOrEmpty": "上传文件不能为空!",
"FileNotFound": "指定的文件不存在!",
"PathNotFound": "指定的目录不存在!",
"FilePathNotFound": "文件或目录不存在!",

13
aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi/LINGYUN/Abp/OssManagement/StaticFilesController.cs

@ -1,4 +1,5 @@
using LINGYUN.Abp.OssManagement.Permissions;
using LINGYUN.Abp.OssManagement.Localization;
using LINGYUN.Abp.OssManagement.Permissions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@ -28,6 +29,8 @@ namespace LINGYUN.Abp.OssManagement
{
_ossObjectAppService = ossObjectAppService;
_staticFilesAppServic = staticFilesAppServic;
LocalizationResource = typeof(AbpOssManagementResource);
}
[HttpPost]
@ -35,9 +38,9 @@ namespace LINGYUN.Abp.OssManagement
[Route("{bucket}/p/{path}")]
[Route("{bucket}/p/{path}/{name}")]
[Authorize(AbpOssManagementPermissions.OssObject.Create)]
public virtual async Task<OssObjectDto> UploadAsync(string bucket, string path, string name, [FromForm] IFormFile file)
public virtual async Task<OssObjectDto> UploadAsync(string bucket, string path, string name)
{
if (file == null || file.Length <= 0)
if (Request.ContentLength <= 0)
{
ThrowValidationException(L["FileNotBeNullOrEmpty"], "File");
}
@ -46,8 +49,8 @@ namespace LINGYUN.Abp.OssManagement
{
Bucket = HttpUtility.UrlDecode(bucket),
Path = HttpUtility.UrlDecode(path),
Object = name ?? file.FileName,
Content = file.OpenReadStream(),
Object = name ?? Request.Form.Files[0].FileName,
Content = Request.Form.Files[0].OpenReadStream(),
Overwrite = true
};

Loading…
Cancel
Save