fix: 【数据源】数据源新增对远程 Excel/CSV 的支持 #14681

This commit is contained in:
taojinlong
2025-03-05 15:03:06 +08:00
committed by taojinlong
parent 5cb31d140e
commit 8d4922d88a
2 changed files with 11 additions and 13 deletions

View File

@@ -67,6 +67,7 @@ public class HttpClientUtil {
throw new DEException(SYSTEM_INNER_ERROR.code(), "HttpClient查询失败: " + e.getMessage());
}
}
private static CloseableHttpClient buildHttpClient(boolean ssl) {
try {
if (ssl) {
@@ -381,17 +382,13 @@ public class HttpClientUtil {
String tranName = UUID.randomUUID().toString() + "." + suffix;
name.put("fileName", fileName);
name.put("tranName", tranName);
try {
FileOutputStream outputStream = new FileOutputStream(path + tranName);
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = response.getEntity().getContent().read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
} finally {
File localFile = new File(path + tranName);
FileOutputStream outputStream = new FileOutputStream(localFile);
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = response.getEntity().getContent().read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
} catch (Exception e) {
logger.error("HttpClient查询失败", e);
throw new RuntimeException("HttpClient查询失败: " + e.getMessage(), e);