修改图片上传和视频上传限制可配置化
This commit is contained in:
parent
9edbe83376
commit
a0c94f3eac
@ -16,4 +16,6 @@ public class FileUploadSettings
|
||||
{
|
||||
public long MaxFileSize { get; set; } = 3 * 1024 * 1024; // 5MB
|
||||
public List<string> AllowedContentTypes { get; set; } = new();
|
||||
public int DailyUploadLimit { get; set; } = 5;
|
||||
public int VideoDailyUploadLimit { get; set; } = 50;
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ namespace LMS.service.Service.FileUploadService
|
||||
{
|
||||
// 3. 校验当前用户是不是超出了上传限制
|
||||
var userFilesCount = await GetUserUploadToday(userId.Value, request.Type);
|
||||
if (userFilesCount >= 5)
|
||||
if (userFilesCount >= _uploadSettings.DailyUploadLimit)
|
||||
{
|
||||
return APIResponseModel<UploadResult>.CreateErrorResponseModel(ResponseCode.ParameterError, "今日上传文件数量已达上限,请明天再试");
|
||||
}
|
||||
@ -104,7 +104,7 @@ namespace LMS.service.Service.FileUploadService
|
||||
else
|
||||
{
|
||||
var userFilesCount = await GetUserUploadToday(userId.Value, request.Type);
|
||||
if (userFilesCount >= 50)
|
||||
if (userFilesCount >= _uploadSettings.VideoDailyUploadLimit)
|
||||
{
|
||||
return APIResponseModel<UploadResult>.CreateErrorResponseModel(ResponseCode.ParameterError, "今日上传文件数量已达上限,请明天再试");
|
||||
}
|
||||
|
||||
@ -76,7 +76,9 @@
|
||||
"image/png",
|
||||
"image/gif",
|
||||
"image/webp"
|
||||
]
|
||||
],
|
||||
"DailyUploadLimit": 100,
|
||||
"VideoDailyUploadLimit": 50
|
||||
},
|
||||
"Version": "1.1.5",
|
||||
"AllowedHosts": "*"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user