mirror of
https://github.com/dataease/dataease.git
synced 2026-05-18 01:38:11 +08:00
fix: 修复下载远程Excel文件失败
This commit is contained in:
@@ -422,8 +422,8 @@ public class ExcelUtils {
|
||||
Map<String, String> fileNames = new HashMap<>();
|
||||
if (remoteExcelRequest.getUrl().trim().startsWith("http")) {
|
||||
HttpClientConfig httpClientConfig = new HttpClientConfig();
|
||||
if (StringUtils.isNotEmpty(remoteExcelRequest.getUsername()) && StringUtils.isNotEmpty(remoteExcelRequest.getPassword())) {
|
||||
String authValue = "Basic " + Base64.getUrlEncoder().encodeToString((remoteExcelRequest.getUsername() + ":" + remoteExcelRequest.getPassword()).getBytes());
|
||||
if (StringUtils.isNotEmpty(remoteExcelRequest.getUserName()) && StringUtils.isNotEmpty(remoteExcelRequest.getPasswd())) {
|
||||
String authValue = "Basic " + Base64.getUrlEncoder().encodeToString((new String(Base64.getDecoder().decode(remoteExcelRequest.getUserName())) + ":" + new String(Base64.getDecoder().decode(remoteExcelRequest.getPasswd()))).getBytes());
|
||||
httpClientConfig.addHeader("Authorization", authValue);
|
||||
}
|
||||
File p = new File(path);
|
||||
@@ -755,9 +755,9 @@ public class ExcelUtils {
|
||||
DEException.throwException("无效的地址!");
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(remoteExcelRequest.getUsername()) && StringUtils.isNotEmpty(remoteExcelRequest.getPassword())) {
|
||||
username = remoteExcelRequest.getUsername();
|
||||
password = remoteExcelRequest.getPassword();
|
||||
if (StringUtils.isNotEmpty(remoteExcelRequest.getUserName()) && StringUtils.isNotEmpty(remoteExcelRequest.getPasswd())) {
|
||||
username = new String(Base64.getDecoder().decode(remoteExcelRequest.getUserName()));
|
||||
password = new String(Base64.getDecoder().decode(remoteExcelRequest.getPasswd()));
|
||||
}
|
||||
int port = 21;
|
||||
String suffix = filePath.substring(filePath.lastIndexOf(".") + 1);
|
||||
|
||||
@@ -382,6 +382,8 @@ const loadData = () => {
|
||||
remoteExcelForm.value.validate(val => {
|
||||
if (val) {
|
||||
const request = JSON.parse(JSON.stringify(form.value.configuration))
|
||||
request.userName = Base64.encode(request.userName)
|
||||
request.passwd = Base64.encode(request.passwd)
|
||||
request.datasourceId = form.value.id || 0
|
||||
request.editType = form.value.editType
|
||||
loading.value = true
|
||||
@@ -411,6 +413,11 @@ const loadData = () => {
|
||||
|
||||
const uploadSuccess = response => {
|
||||
if (!response) {
|
||||
state.excelData = []
|
||||
activeTab.value = ''
|
||||
tabList.value = []
|
||||
Object.assign(sheetObj, cloneDeep(defaultSheetObj))
|
||||
ElMessage.warning(response.msg)
|
||||
return
|
||||
}
|
||||
if (response?.code !== 0) {
|
||||
|
||||
@@ -410,6 +410,8 @@ const doValidateDs = request => {
|
||||
let excelRequest = JSON.parse(JSON.stringify(form2.configuration))
|
||||
excelRequest.datasourceId = form2.id || 0
|
||||
excelRequest.editType = form2.editType
|
||||
excelRequest.userName = Base64.encode(request.userName)
|
||||
excelRequest.passwd = Base64.encode(request.passwd)
|
||||
return loadRemoteFile(excelRequest)
|
||||
.then(() => {
|
||||
ElMessage.success(t('datasource.validate_success'))
|
||||
|
||||
@@ -8,6 +8,6 @@ import java.util.List;
|
||||
public class ExcelConfiguration {
|
||||
private String url;
|
||||
private List<ExcelSheetData> sheets;
|
||||
private String username;
|
||||
private String password;
|
||||
private String userName;
|
||||
private String passwd;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user