修复 下载方法 包含空格 和+转换错误的问题 调整下载方法输出报错方式

This commit is contained in:
gaoxiongzaq
2023-10-24 16:51:26 +08:00
parent 724db1936b
commit 7597864337
2 changed files with 5 additions and 9 deletions

View File

@@ -22,6 +22,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Map;
import java.util.UUID;
@@ -54,7 +55,7 @@ public class DownloadUtils {
String urlStr = null;
try {
SslUtils.ignoreSsl();
urlStr = fileAttribute.getUrl().replaceAll("\\+", "%20");
urlStr = fileAttribute.getUrl().replaceAll("\\+", "%2B").replaceAll(" ", "%20");
} catch (Exception e) {
logger.error("忽略SSL证书异常:", e);
}
@@ -110,16 +111,11 @@ public class DownloadUtils {
FileUtils.copyToFile(fileResponse.getBody(), realFile);
return null;
});
} catch (RestClientException e) {
if (e.getMessage().contains("404 Not Found") || e.getMessage().contains("403 Not Found") || e.getMessage().contains("500 Not Found") ){
} catch (Exception e) {
response.setCode(1);
response.setContent(null);
response.setMsg("下载失败:" + e);
return response;
}else {
e.printStackTrace();
}
}
} else if (isFtpUrl(url)) {
String ftpUsername = WebUtils.getUrlParameterReg(fileAttribute.getUrl(), URL_PARAM_FTP_USERNAME);