diff --git a/server/pom.xml b/server/pom.xml index 064ff85e..60808d7d 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -105,11 +105,6 @@ fr.opensagres.xdocreport.document 1.0.5 - - commons-io - commons-io - 2.4 - org.apache.commons diff --git a/server/src/main/java/cn/keking/service/impl/SimTextFilePreviewImpl.java b/server/src/main/java/cn/keking/service/impl/SimTextFilePreviewImpl.java index 95156e85..2a2751cf 100644 --- a/server/src/main/java/cn/keking/service/impl/SimTextFilePreviewImpl.java +++ b/server/src/main/java/cn/keking/service/impl/SimTextFilePreviewImpl.java @@ -5,8 +5,8 @@ import cn.keking.model.ReturnResponse; import cn.keking.service.FilePreview; import cn.keking.utils.DownloadUtils; import cn.keking.utils.KkFileUtils; +import jodd.io.FileUtil; import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.FileUtils; import org.springframework.stereotype.Service; import org.springframework.ui.Model; @@ -36,7 +36,7 @@ public class SimTextFilePreviewImpl implements FilePreview { try { File originFile = new File(response.getContent()); String charset = KkFileUtils.getFileEncode(originFile); - String fileData = FileUtils.readFileToString(originFile, charset); + String fileData = FileUtil.readString(originFile, charset); model.addAttribute("textData", Base64.encodeBase64String(fileData.getBytes())); } catch (IOException e) { return otherFilePreview.notSupportedFile(model, fileAttribute, e.getLocalizedMessage()); diff --git a/server/src/main/java/cn/keking/utils/DownloadUtils.java b/server/src/main/java/cn/keking/utils/DownloadUtils.java index 76f03c50..1ba05cff 100644 --- a/server/src/main/java/cn/keking/utils/DownloadUtils.java +++ b/server/src/main/java/cn/keking/utils/DownloadUtils.java @@ -4,7 +4,8 @@ import cn.keking.config.ConfigConstants; import cn.keking.model.FileAttribute; import cn.keking.model.ReturnResponse; import io.mola.galimatias.GalimatiasParseException; -import org.apache.commons.io.FileUtils; +import jodd.io.FileUtil; +import jodd.io.NetUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +40,7 @@ public class DownloadUtils { URL url = WebUtils.normalizedURL(urlStr); if (isHttpUrl(url)) { File realFile = new File(realPath); - FileUtils.copyURLToFile(url, realFile); + NetUtil.downloadFile(url.toString(),realFile); } else if (isFtpUrl(url)) { String ftpUsername = WebUtils.getUrlParameterReg(fileAttribute.getUrl(), URL_PARAM_FTP_USERNAME); String ftpPassword = WebUtils.getUrlParameterReg(fileAttribute.getUrl(), URL_PARAM_FTP_PASSWORD); diff --git a/server/src/main/java/cn/keking/web/controller/OnlinePreviewController.java b/server/src/main/java/cn/keking/web/controller/OnlinePreviewController.java index c11cc406..5d6c644d 100644 --- a/server/src/main/java/cn/keking/web/controller/OnlinePreviewController.java +++ b/server/src/main/java/cn/keking/web/controller/OnlinePreviewController.java @@ -8,9 +8,10 @@ import cn.keking.service.cache.CacheService; import cn.keking.service.impl.OtherFilePreviewImpl; import cn.keking.service.FileHandlerService; import cn.keking.utils.WebUtils; +import fr.opensagres.xdocreport.core.io.IOUtils; import io.mola.galimatias.GalimatiasParseException; +import jodd.io.NetUtil; import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; @@ -103,7 +104,7 @@ public class OnlinePreviewController { logger.info("下载跨域pdf文件url:{}", urlPath); try { URL url = WebUtils.normalizedURL(urlPath); - byte[] bytes = IOUtils.toByteArray(url); + byte[] bytes = NetUtil.downloadBytes(url.toString()); IOUtils.write(bytes, response.getOutputStream()); } catch (IOException | GalimatiasParseException e) { logger.error("下载跨域pdf文件异常,url:{}", urlPath, e);