From cc7da000014ac1e2ae98732b70f0db28dce81221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E9=9B=84?= Date: Mon, 3 Apr 2023 07:11:14 +0000 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E5=8C=85=E5=AF=86=E7=A0=81=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DLINUX=E4=B8=8B=E4=B8=AD=E6=96=87=E4=B9=B1=E7=A0=81=20?= =?UTF-8?q?=E8=A7=A3=E5=8E=8B=E6=94=AF=E6=8C=81=E6=96=87=E4=BB=B6=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=20=E6=96=B0=E5=A2=9E=20=E6=94=AF=E6=8C=81=E5=8E=8B?= =?UTF-8?q?=E7=BC=A9=E5=8C=85=E5=AF=86=E7=A0=81=20=E4=BF=AE=E5=A4=8DLINUX?= =?UTF-8?q?=E4=B8=8B=E4=B8=AD=E6=96=87=E4=B9=B1=E7=A0=81=20=E8=A7=A3?= =?UTF-8?q?=E5=8E=8B=E6=94=AF=E6=8C=81=E6=96=87=E4=BB=B6=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 高雄 --- .../java/cn/keking/utils/DownloadUtils.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/cn/keking/utils/DownloadUtils.java b/server/src/main/java/cn/keking/utils/DownloadUtils.java index 2c4b5b56..c4a17383 100644 --- a/server/src/main/java/cn/keking/utils/DownloadUtils.java +++ b/server/src/main/java/cn/keking/utils/DownloadUtils.java @@ -3,16 +3,17 @@ package cn.keking.utils; import cn.keking.config.ConfigConstants; import cn.keking.model.FileAttribute; import cn.keking.model.ReturnResponse; -import cn.keking.service.FileHandlerService; import io.mola.galimatias.GalimatiasParseException; import org.apache.commons.io.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.StringUtils; -import org.springframework.web.util.HtmlUtils; -import java.io.*; -import java.net.*; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URL; +import java.net.URLDecoder; import java.util.UUID; import static cn.keking.utils.KkFileUtils.isFtpUrl; @@ -36,13 +37,24 @@ public class DownloadUtils { */ public static ReturnResponse downLoad(FileAttribute fileAttribute, String fileName) { // 忽略ssl证书 + String urlStr = null; + String urlStrr = null; + URL urll; try { SslUtils.ignoreSsl(); + urlStr = fileAttribute.getUrl().replaceAll("\\+", "%20"); + urll = new URL(urlStr); + urlStrr = URLDecoder.decode(urll.getPath(), "UTF-8"); } catch (Exception e) { logger.error("忽略SSL证书异常:", e); } - String urlStr = fileAttribute.getUrl().replaceAll("\\+", "%20"); ReturnResponse response = new ReturnResponse<>(0, "下载成功!!!", ""); + assert urlStr != null; + if (urlStr.contains("?fileKey=")) { + response.setContent(fileDir + urlStrr); + response.setMsg(fileName); + return response; + } String realPath = DownloadUtils.getRelFilePath(fileName, fileAttribute); if(!StringUtils.hasText(realPath)){ response.setCode(1);