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