From 67e66f297f65d00d502c02eb88e1ae07f722133e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LI-CCONG=5C=E6=9D=8E=E8=81=AA=E8=81=AA?= <1441652193@qq.com> Date: Fri, 29 Mar 2024 10:27:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E9=97=AE?= =?UTF-8?q?=E9=A2=98bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cc/yunxi/service/impl/FileServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nxhs-service/src/main/java/cc/yunxi/service/impl/FileServiceImpl.java b/nxhs-service/src/main/java/cc/yunxi/service/impl/FileServiceImpl.java index 0692985..686a01a 100644 --- a/nxhs-service/src/main/java/cc/yunxi/service/impl/FileServiceImpl.java +++ b/nxhs-service/src/main/java/cc/yunxi/service/impl/FileServiceImpl.java @@ -126,17 +126,17 @@ public class FileServiceImpl extends ServiceImpl implements IF } // 生成md5文件名 String hashName = FileUtils.generateName(content, originalName); + // 确定上传路径 + String URI = basePath + fileStyleEnum.toString().toLowerCase() + "/" + hashName; + String fullPath = System.getProperty("user.dir") + URI; // 判断文件是否存在,如果存在直接返回 FileUploadRespVO uploadRespVO = new FileUploadRespVO(); File fileInfo = getFileInfoByHashVal(hashName); - if (fileInfo != null) { + if (fileInfo != null && FileUtil.exist(fullPath)) { uploadRespVO.setName(fileInfo.getFilename()); uploadRespVO.setUrl(fileInfo.getUrl()); uploadRespVO.setField(fileInfo.getHashVal()); } else { - // 确定上传路径 - String URI = basePath + fileStyleEnum.toString().toLowerCase() + "/" + hashName; - String fullPath = System.getProperty("user.dir") + URI; // 上传到文件存储位置 FileUtil.writeBytes(content, fullPath); uploadRespVO.setName(originalName);