From 2fe919b6ceeab958d1d5e65a8b39fca129f0e6c5 Mon Sep 17 00:00:00 2001 From: 若依 <yzz_ivy@163.com> Date: 星期一, 01 十一月 2021 13:28:59 +0800 Subject: [PATCH] !361 优化一些布尔判断语法 Merge pull request !361 from 清溪先生/master --- ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java index daa9498..76b647a 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java @@ -127,18 +127,21 @@ return fileName; } - private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException + public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException { File desc = new File(uploadDir + File.separator + fileName); - if (!desc.exists()) { - if (!desc.getParentFile().exists()) { + + if (!desc.exists()) + { + if (!desc.getParentFile().exists()) + { desc.getParentFile().mkdirs(); } } return desc; } - private static final String getPathFileName(String uploadDir, String fileName) throws IOException + public static final String getPathFileName(String uploadDir, String fileName) throws IOException { int dirLastIndex = RuoYiConfig.getProfile().length() + 1; String currentDir = StringUtils.substring(uploadDir, dirLastIndex); @@ -182,6 +185,11 @@ throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, fileName); } + else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION) + { + throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension, + fileName); + } else { throw new InvalidExtensionException(allowedExtension, extension, fileName); -- Gitblit v1.9.2