fix: MinioRepository中optimizedFileUpload函数文件大小判定无效
This commit is contained in:
+2
-17
@@ -191,9 +191,8 @@ public class MinioRepository {
|
|||||||
throw new BadRequestException("文件名不能为空");
|
throw new BadRequestException("文件名不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.getSize() > properties.getOss().getMaxSize()) {
|
long size = file.getSize();
|
||||||
throw new BadRequestException("文件大小超出限制,最大允许上传 100 MB");
|
CsFileUtil.checkSize(properties.getOss().getMaxSize(), size);
|
||||||
}
|
|
||||||
|
|
||||||
String fileName = UUID.randomUUID() + getFileExtension(originalFilename);
|
String fileName = UUID.randomUUID() + getFileExtension(originalFilename);
|
||||||
// yyyy/MM/dd/fileName.xxx
|
// yyyy/MM/dd/fileName.xxx
|
||||||
@@ -248,20 +247,6 @@ public class MinioRepository {
|
|||||||
return lastIndex == -1 ? "" : fileName.substring(lastIndex);
|
return lastIndex == -1 ? "" : fileName.substring(lastIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证文件大小 限制上传的文件大小
|
|
||||||
*
|
|
||||||
* @param file 文件
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public boolean validateFileSize(MultipartFile file) {
|
|
||||||
if (file.getSize() > properties.getOss().getMaxSize()) {
|
|
||||||
log.warn("文件超出大小限制,最大允许上传 100 MB,当前文件大小: {}", file.getSize());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成文件的预签名 URL,用于文件预览
|
* 生成文件的预签名 URL,用于文件预览
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user