From 10f93cfd6bf59fa7fc07f12c2202670ee27a4e2d Mon Sep 17 00:00:00 2001 From: heminjian502 Date: Thu, 18 Aug 2022 19:19:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BB=E7=94=9F=E5=BE=AE=E4=BF=A1=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/common/utils/StringUtils.java | 13 +++++++++++++ .../ruoyi/common/utils/file/FileUploadUtils.java | 1 + 2 files changed, 14 insertions(+) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java index 6b70889..f653af3 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java @@ -6,6 +6,9 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import org.springframework.util.AntPathMatcher; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.text.StrFormatter; @@ -580,4 +583,14 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils } return sb.toString(); } + + public static String replaceBlank(String str) { + String dest = ""; + if (str!=null) { + Pattern p = Pattern.compile("\\s*|\t|\r|\n"); + Matcher m = p.matcher(str); + dest = m.replaceAll(""); + } + return dest; + } } \ No newline at end of file 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 62be0fc..dba7c37 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 @@ -242,6 +242,7 @@ public class FileUploadUtils public static String generateImage(String file, String uploadFilePath) { // 解密 try { + file = StringUtils.replaceBlank(file); // 图片分类路径+图片名+图片后缀 String imgClassPath = UUID.randomUUID().toString().concat(".jpg"); // 解密