修改上传文件超过100m提示
This commit is contained in:
+5
-5
@@ -85,11 +85,11 @@ public class JeroBootExceptionHandler {
|
|||||||
/**
|
/**
|
||||||
* spring默认上传大小100MB 超出大小捕获异常MaxUploadSizeExceededException
|
* spring默认上传大小100MB 超出大小捕获异常MaxUploadSizeExceededException
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(MaxUploadSizeExceededException.class)
|
// @ExceptionHandler(MaxUploadSizeExceededException.class)
|
||||||
public Result<?> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) {
|
// public Result<?> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) {
|
||||||
log.error(e.getMessage(), e);
|
// log.error(e.getMessage(), e);
|
||||||
return Result.error("文件大小超出100MB限制, 请压缩或降低文件质量! ");
|
// return Result.error("文件大小超出100MB限制, 请压缩或降低文件质量! ");
|
||||||
}
|
// }
|
||||||
|
|
||||||
@ExceptionHandler(DataIntegrityViolationException.class)
|
@ExceptionHandler(DataIntegrityViolationException.class)
|
||||||
public Result<?> handleDataIntegrityViolationException(DataIntegrityViolationException e) {
|
public Result<?> handleDataIntegrityViolationException(DataIntegrityViolationException e) {
|
||||||
|
|||||||
+27
-27
@@ -72,15 +72,15 @@ public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> impl
|
|||||||
public OSSFile uploadLocal(MultipartFile mf, String bizPath, String state, String cut) {
|
public OSSFile uploadLocal(MultipartFile mf, String bizPath, String state, String cut) {
|
||||||
|
|
||||||
//处理文件大小,大于100M抛出异常
|
//处理文件大小,大于100M抛出异常
|
||||||
long fileSize = mf.getSize() / 1024 / 1024;
|
// long fileSize = mf.getSize() / 1024 / 1024;
|
||||||
String originalFilename = mf.getOriginalFilename();
|
// String originalFilename = mf.getOriginalFilename();
|
||||||
if (fileSize >= 100) {
|
// if (fileSize >= 100) {
|
||||||
if (cut.equals(CutEnum.CN.getValue())) {
|
// if (cut.equals(CutEnum.CN.getValue())) {
|
||||||
throw new JeroBootException(originalFilename + "文件大小超出100MB, 请压缩或降低文件质量!");
|
// throw new JeroBootException(originalFilename + "文件大小超出100MB, 请压缩或降低文件质量!");
|
||||||
} else {
|
// } else {
|
||||||
throw new JeroBootException(originalFilename + "File size out 100MB, Please compress or reduce file quality!");
|
// throw new JeroBootException(originalFilename + "File size out 100MB, Please compress or reduce file quality!");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
OSSFile oSSFile = new OSSFile();
|
OSSFile oSSFile = new OSSFile();
|
||||||
try {
|
try {
|
||||||
@@ -191,15 +191,15 @@ public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> impl
|
|||||||
public OSSFile uploadLocalOfCos(MultipartFile mf, String bizPath, String state, String cut) {
|
public OSSFile uploadLocalOfCos(MultipartFile mf, String bizPath, String state, String cut) {
|
||||||
|
|
||||||
//处理文件大小,大于100M抛出异常
|
//处理文件大小,大于100M抛出异常
|
||||||
long fileSize = mf.getSize() / 1024 / 1024;
|
// long fileSize = mf.getSize() / 1024 / 1024;
|
||||||
String originalFilename = mf.getOriginalFilename();
|
// String originalFilename = mf.getOriginalFilename();
|
||||||
if (fileSize >= 100) {
|
// if (fileSize >= 100) {
|
||||||
if (cut.equals(CutEnum.CN.getValue())) {
|
// if (cut.equals(CutEnum.CN.getValue())) {
|
||||||
throw new JeroBootException(originalFilename + "文件大小超出100MB, 请压缩或降低文件质量!");
|
// throw new JeroBootException(originalFilename + "文件大小超出100MB, 请压缩或降低文件质量!");
|
||||||
} else {
|
// } else {
|
||||||
throw new JeroBootException(originalFilename + "File size out 100MB, Please compress or reduce file quality!");
|
// throw new JeroBootException(originalFilename + "File size out 100MB, Please compress or reduce file quality!");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
OSSFile oSSFile = new OSSFile();
|
OSSFile oSSFile = new OSSFile();
|
||||||
String ctxPath = uploadCospath;
|
String ctxPath = uploadCospath;
|
||||||
@@ -296,15 +296,15 @@ public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> impl
|
|||||||
public OSSFile uploadLocalForSplit(MultipartFile mf, String bizPath, String state, String cut) {
|
public OSSFile uploadLocalForSplit(MultipartFile mf, String bizPath, String state, String cut) {
|
||||||
|
|
||||||
//处理文件大小,大于100M抛出异常
|
//处理文件大小,大于100M抛出异常
|
||||||
long fileSize = mf.getSize() / 1024 / 1024;
|
// long fileSize = mf.getSize() / 1024 / 1024;
|
||||||
String originalFilename = mf.getOriginalFilename();
|
// String originalFilename = mf.getOriginalFilename();
|
||||||
if (fileSize >= 100) {
|
// if (fileSize >= 100) {
|
||||||
if (cut.equals(CutEnum.CN.getValue())) {
|
// if (cut.equals(CutEnum.CN.getValue())) {
|
||||||
throw new JeroBootException(originalFilename + "文件大小超出100MB, 请压缩或降低文件质量!");
|
// throw new JeroBootException(originalFilename + "文件大小超出100MB, 请压缩或降低文件质量!");
|
||||||
} else {
|
// } else {
|
||||||
throw new JeroBootException(originalFilename + "File size out 100MB, Please compress or reduce file quality!");
|
// throw new JeroBootException(originalFilename + "File size out 100MB, Please compress or reduce file quality!");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
OSSFile oSSFile = new OSSFile();
|
OSSFile oSSFile = new OSSFile();
|
||||||
String ctxPath = uploadCospath;
|
String ctxPath = uploadCospath;
|
||||||
|
|||||||
Reference in New Issue
Block a user