fix 文件大小处理
This commit is contained in:
@@ -42,8 +42,10 @@ public class FileController : ControllerBase
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Authorize(Roles = "admin")]
|
||||
[HttpPost("{Bucket}/version/upload")]
|
||||
[RequestSizeLimit(300_000_000)]
|
||||
[RequestFormLimits(MultipartBodyLengthLimit = int.MaxValue)]
|
||||
[RequestSizeLimit(int.MaxValue)]
|
||||
public async Task<string> UploadFileAsync([FromForm] FileVersionUploadRequest request)
|
||||
{
|
||||
return await _fileVersionService.UploadFileAsync(request);
|
||||
|
||||
@@ -15,7 +15,7 @@ public class FileVersionUploadRequest : IValidatableObject
|
||||
/// <summary>
|
||||
/// 文件
|
||||
/// </summary>
|
||||
[Required]
|
||||
[FromForm]
|
||||
public IFormFile File { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -58,7 +58,7 @@ public class FileVersionService : IFileVersionService
|
||||
.Where(x => x.Code == code)
|
||||
.OrderByDescending(x => x.Version)
|
||||
.Select<FileVersionResponse>()
|
||||
.SingleAsync();
|
||||
.FirstAsync();
|
||||
}
|
||||
|
||||
//************************************************************* help methods ***************************************************************
|
||||
@@ -69,6 +69,6 @@ public class FileVersionService : IFileVersionService
|
||||
.Where(x => x.Code == code)
|
||||
.OrderByDescending(x => x.Version)
|
||||
.Select(x => x.Version)
|
||||
.SingleAsync();
|
||||
.FirstAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Common.FileOperation.Configurations;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Minio;
|
||||
using Minio.DataModel.Args;
|
||||
@@ -50,6 +51,8 @@ public class MinioService : IMinioService
|
||||
|
||||
public async Task<string> UploadFileAsync(string bucket, IFormFile formFile)
|
||||
{
|
||||
formFile.ThrowIfNull("请选择文件上传!");
|
||||
|
||||
await CreateBucketIfNotExistsAsync(bucket);
|
||||
|
||||
var ms = DateTime.Now.ToString("yyyyMMddHHmmssfff");
|
||||
|
||||
@@ -18,13 +18,13 @@ public class FileVersionEntity : SugarBaseEntity
|
||||
/// <summary>
|
||||
/// 文件code
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, ColumnDescription = "文件code", UniqueGroupNameList = new[] { "idx_FileVersion_Code" })]
|
||||
[SugarColumn(IsNullable = false, ColumnDescription = "文件code", UniqueGroupNameList = new[] { "idx_FileVersion_Code_Version" })]
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 版本号
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, ColumnDescription = "版本号")]
|
||||
[SugarColumn(IsNullable = false, ColumnDescription = "版本号", UniqueGroupNameList = new[] { "idx_FileVersion_Code_Version" })]
|
||||
public int Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user