From 37bf0d609b9a04fd20edccc0983697149c0b3059 Mon Sep 17 00:00:00 2001 From: meng <154040976@qq.com> Date: Sun, 25 Nov 2018 13:31:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81blob=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20--=E5=90=AC=E4=B8=80=E9=A6=96=E6=AD=8C=EF=BC=8C?= =?UTF-8?q?=E5=9B=9E=E5=BF=86=E4=B8=80=E6=AE=B5=E5=BE=80=E4=BA=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/len/util/UploadUtil.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/len-core/src/main/java/com/len/util/UploadUtil.java b/len-core/src/main/java/com/len/util/UploadUtil.java index 6f66788..25ff7d9 100644 --- a/len-core/src/main/java/com/len/util/UploadUtil.java +++ b/len-core/src/main/java/com/len/util/UploadUtil.java @@ -68,14 +68,22 @@ public class UploadUtil { public LoadType fileNameStyle(MultipartFile multipartFile) { String curr = multipartFile.getOriginalFilename(); int suffixLen = curr.lastIndexOf("."); - if (suffixLen == -1) { + boolean flag=false; + int index=-1; + if("blob".equals(curr)){ + flag=true; + index=0; + curr=UUID.randomUUID() + ".png"; + } else if (suffixLen == -1) { throw new MyException("文件获取异常"); } - String suffix = curr.substring(suffixLen, curr.length()); - int index = Arrays.binarySearch(IMAGE_SUFFIX.split(","), - suffix.replace(".", "")); + if(!flag){ + String suffix = curr.substring(suffixLen, curr.length()); + index = Arrays.binarySearch(IMAGE_SUFFIX.split(","), + suffix.replace(".", "")); - curr = UUID.randomUUID() + suffix; + curr = UUID.randomUUID() + suffix; + } LoadType loadType = new LoadType(); loadType.setFileName(curr); //image 情况