From b1a81526e8fbd3e67df8e971f0de110e5e6dac75 Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 15 Dec 2021 14:01:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=9A=E5=BB=BA=E5=A3=B0=E9=9F=B3=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=A7=86=E9=A2=91=E4=B8=8A=E4=BC=A0=20=E4=B8=8D?= =?UTF-8?q?=E9=99=90=E6=A0=BC=E5=BC=8F=E5=8F=AA=E9=99=90=E5=88=B6=E6=98=AF?= =?UTF-8?q?=E8=A7=86=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/controller/OssController.java | 11 ++++++++++- .../src/main/java/com/epmet/utils/ModuleConstant.java | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java index 47be7d427a..244eb91ca9 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java @@ -219,7 +219,9 @@ public class OssController { if (!MediaType.IMAGE_PNG_VALUE.equals(file.getContentType()) && !MediaType.IMAGE_JPEG_VALUE.equals(file.getContentType()) && !ModuleConstant.FILE_CONTENT_TYPE_JPG.equals(file.getContentType()) - && !ModuleConstant.FILE_CONTENT_TYPE_PDF.equals(file.getContentType())) { + && !ModuleConstant.FILE_CONTENT_TYPE_PDF.equals(file.getContentType()) + && !file.getContentType().startsWith(ModuleConstant.FILE_CONTENT_TYPE_VEDIO_PREFIX) + ) { log.error("uploadArticleImg file type:{} is not support 2 upload", file.getContentType()); throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getCode() , EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getMsg()); @@ -232,6 +234,13 @@ public class OssController { throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); } + } else if (file.getContentType().startsWith(ModuleConstant.FILE_CONTENT_TYPE_VEDIO_PREFIX)) { + // 校验文件大小,不超过5m + long maxSize = 25 * 1024 * 1024; + if (size > maxSize) { + throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() + , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); + } } else { // 校验文件大小,不超过2m long maxSize = 2 * 1024 * 1024; diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/utils/ModuleConstant.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/utils/ModuleConstant.java index 71d5f177e2..d713004471 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/utils/ModuleConstant.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/utils/ModuleConstant.java @@ -30,6 +30,10 @@ public interface ModuleConstant extends Constant { * pdf文件类型 */ String FILE_CONTENT_TYPE_PDF = "application/pdf"; + /** + * vedio文件类型前缀 不具体什么视频格式了 + */ + String FILE_CONTENT_TYPE_VEDIO_PREFIX = "video/"; /** * 项目附件-允许上传的文件类型