From bc7551f40f53946a7877342e67262cac8b510740 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Wed, 27 Mar 2024 16:05:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BB=BB=E6=84=8F=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8D=E5=AE=89=E5=85=A8=E6=93=8D=E4=BD=9C=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../visualization/server/StaticResourceServer.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/visualization/server/StaticResourceServer.java b/core/core-backend/src/main/java/io/dataease/visualization/server/StaticResourceServer.java index 840efa6350..d8a4962c7a 100644 --- a/core/core-backend/src/main/java/io/dataease/visualization/server/StaticResourceServer.java +++ b/core/core-backend/src/main/java/io/dataease/visualization/server/StaticResourceServer.java @@ -43,9 +43,10 @@ public class StaticResourceServer implements StaticResourceApi { } String originName = file.getOriginalFilename(); String newFileName = fileId + originName.substring(originName.lastIndexOf("."), originName.length()); - Path uploadPath = Paths.get(staticDir.toString(), newFileName); + Path basePath = Paths.get(staticDir.toString()); // create dir is absent - FileUtils.createIfAbsent(Paths.get(staticDir.toString())); + FileUtils.createIfAbsent(basePath); + Path uploadPath = basePath.resolve(newFileName); Files.createFile(uploadPath); file.transferTo(uploadPath); } catch (IOException e) { @@ -82,9 +83,10 @@ public class StaticResourceServer implements StaticResourceApi { } public void saveSingleFileToServe(String fileName, String content) { - Path uploadPath = Paths.get(staticDir.toString(), fileName); + Path basePath = Paths.get(staticDir.toString()); + Path uploadPath = basePath.resolve(fileName); try { - if (uploadPath.toFile().exists()) { + if (Files.exists(uploadPath)) { LogUtil.info("file exists"); } else { if (StringUtils.isNotEmpty(content)) {