|
|
@ -166,4 +166,24 @@ public class OssController { |
|
|
|
return ossService.uploadImg(file); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("function/upload") |
|
|
|
public Result uploadFunctionLogo(@RequestParam("file") MultipartFile file) { |
|
|
|
|
|
|
|
// 校验文件类型
|
|
|
|
if (!MediaType.IMAGE_PNG_VALUE.equals(file.getContentType())) { |
|
|
|
throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getCode() |
|
|
|
, EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
// 校验文件体积,不超过1m
|
|
|
|
long maxSize = 1024 * 1024; |
|
|
|
long size = file.getSize(); |
|
|
|
if (size > maxSize) { |
|
|
|
throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() |
|
|
|
, EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
return ossService.uploadImg(file); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|