diff --git a/.gitignore b/.gitignore index 7c79eea83..f5768001f 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ nbdist/ server/src/main/cache/ server/src/main/file/ +.DS_Store diff --git a/pom.xml b/pom.xml index 4b09e0a7f..68d9a8ff0 100644 --- a/pom.xml +++ b/pom.xml @@ -11,6 +11,7 @@ 1.8 2.4.2 + 2.17.2 ${java.version} ${java.version} UTF-8 diff --git a/server/pom.xml b/server/pom.xml index c5b123aa3..a980e52db 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -19,11 +19,41 @@ ${spring.boot.version} import pom + + + org.apache.logging.log4j + log4j-api + + + org.apache.logging.log4j + log4j-core + + + org.apache.logging.log4j + log4j-to-slf4j + + + + + org.apache.logging.log4j + log4j-api + ${log4j2.version} + + + org.apache.logging.log4j + log4j-core + ${log4j2.version} + + + org.apache.logging.log4j + log4j-to-slf4j + ${log4j2.version} + org.springframework.boot spring-boot-starter-freemarker diff --git a/server/src/main/java/cn/keking/service/impl/PictureFilePreviewImpl.java b/server/src/main/java/cn/keking/service/impl/PictureFilePreviewImpl.java index 55fee06f9..19e4cf6d0 100644 --- a/server/src/main/java/cn/keking/service/impl/PictureFilePreviewImpl.java +++ b/server/src/main/java/cn/keking/service/impl/PictureFilePreviewImpl.java @@ -1,5 +1,6 @@ package cn.keking.service.impl; +import cn.keking.config.ConfigConstants; import cn.keking.model.FileAttribute; import cn.keking.model.ReturnResponse; import cn.keking.service.FilePreview; @@ -28,6 +29,7 @@ public PictureFilePreviewImpl(FileHandlerService fileHandlerService, OtherFilePr @Override public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) { + String base_url=ConfigConstants.getBaseUrl(); List imgUrls = new ArrayList<>(); imgUrls.add(url); String fileKey = fileAttribute.getFileKey(); @@ -35,14 +37,16 @@ public String filePreviewHandle(String url, Model model, FileAttribute fileAttri if (!CollectionUtils.isEmpty(zipImgUrls)) { imgUrls.addAll(zipImgUrls); } - // 不是http开头,浏览器不能直接访问,需下载到本地 - if (url != null && !url.toLowerCase().startsWith("http")) { + // ftp 或 http 文件先下载到本地 + if (url != null && (url.toLowerCase().startsWith("http")||url.toLowerCase().startsWith("ftp"))) { ReturnResponse response = DownloadUtils.downLoad(fileAttribute, null); if (response.isFailure()) { return otherFilePreview.notSupportedFile(model, fileAttribute, response.getMsg()); } else { String file = fileHandlerService.getRelativePath(response.getContent()); imgUrls.clear(); + //xuenhua 修正currentUrl为下载后文件地址进行预览 + file=base_url+ "/"+file; imgUrls.add(file); model.addAttribute("imgUrls", imgUrls); model.addAttribute("currentUrl", file);