mirror of
https://github.com/dataease/dataease.git
synced 2026-05-15 05:22:13 +08:00
fix: 修复下载远程Excel文件失败
This commit is contained in:
@@ -767,6 +767,7 @@ public class ExcelUtils {
|
||||
fileNames.put("tranName", tranName);
|
||||
FTPClient ftpClient = new FTPClient();
|
||||
try {
|
||||
ftpClient.setConnectTimeout(5 * 1000);
|
||||
ftpClient.connect(serverAddress, port);
|
||||
ftpClient.login(username, password);
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
|
||||
@@ -376,6 +376,13 @@ public class HttpClientUtil {
|
||||
// 设置请求头
|
||||
config.getHeader().forEach(httpGet::addHeader);
|
||||
HttpResponse response = httpClient.execute(httpGet);
|
||||
if (response.getStatusLine().getStatusCode() >= 400) {
|
||||
String msg = EntityUtils.toString(response.getEntity(), config.getCharset());
|
||||
if (StringUtils.isEmpty(msg)) {
|
||||
msg = "StatusCode: " + response.getStatusLine().getStatusCode();
|
||||
}
|
||||
throw new Exception(msg);
|
||||
}
|
||||
String fileName = extractFileName(response, url);
|
||||
String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||
String tranName = UUID.randomUUID().toString() + "." + suffix;
|
||||
|
||||
Reference in New Issue
Block a user