|
|
@@ -35,6 +35,7 @@ const EnterpriseLog = () => { |
|
|
|
allUrl: '', |
|
|
|
seeUrl: '', |
|
|
|
}); |
|
|
|
|
|
|
|
const uploadProps = { |
|
|
|
name: 'file', |
|
|
|
showUploadList: false, |
|
|
@@ -44,15 +45,23 @@ const EnterpriseLog = () => { |
|
|
|
headers: { |
|
|
|
'Content-Type': 'application/octet-stream', |
|
|
|
}, |
|
|
|
customRequest({ action, file, headers, onError, onProgress, onSuccess, withCredentials }) { |
|
|
|
customRequest({ |
|
|
|
action, |
|
|
|
file, |
|
|
|
headers, |
|
|
|
onError, |
|
|
|
onProgress, |
|
|
|
onSuccess, |
|
|
|
withCredentials, |
|
|
|
}) { |
|
|
|
|
|
|
|
//覆盖action 上传之前获取上传地址 |
|
|
|
var index = file.name.lastIndexOf('.'); |
|
|
|
var index = file.name.lastIndexOf("."); |
|
|
|
var ext = file.name.substr(index + 1); |
|
|
|
|
|
|
|
let fileData = null; |
|
|
|
GetCosRequestURL({ directory: "logo", fileExtension: ext, method: "PUT" }).then((r) => { |
|
|
|
SetCosInfo(r) |
|
|
|
action = r.fileUrl + '?' + r.param; |
|
|
|
action = r.allUrl; |
|
|
|
const reader = new FileReader(); |
|
|
|
reader.readAsArrayBuffer(file); |
|
|
|
reader.onload = (e) => { |
|
|
@@ -60,24 +69,20 @@ const EnterpriseLog = () => { |
|
|
|
// 在文件读取结束后执行的操作 |
|
|
|
fileData = e.target.result; |
|
|
|
// 使用 axios 进行文件上传的请求 |
|
|
|
axios |
|
|
|
.put(action, fileData, { |
|
|
|
withCredentials, |
|
|
|
headers, |
|
|
|
onUploadProgress: ({ total, loaded }) => { |
|
|
|
// 进行上传进度输出,更加直观 |
|
|
|
onProgress({ percent: Math.round((loaded / total) * 100).toFixed(2) }, file); |
|
|
|
}, |
|
|
|
}) |
|
|
|
.then((response) => { |
|
|
|
console.log('onSuccess', response, file); |
|
|
|
if (response.status == 200 || response.statusText == 'OK') { |
|
|
|
setUrl(r.seeUrl); |
|
|
|
CompanyInfo.logo = r.seeUrl; |
|
|
|
updateCompany(CompanyInfo); |
|
|
|
} |
|
|
|
// onSuccess(response, file); |
|
|
|
}) |
|
|
|
axios.put(action, fileData, { |
|
|
|
withCredentials, |
|
|
|
headers, |
|
|
|
onUploadProgress: ({ total, loaded }) => { |
|
|
|
// 进行上传进度输出,更加直观 |
|
|
|
onProgress({ percent: Math.round(loaded / total * 100).toFixed(2) }, file); |
|
|
|
}, |
|
|
|
}).then(response => { |
|
|
|
console.log('onSuccess', response, file); |
|
|
|
if (response.status == 200 || response.statusText == 'OK') { |
|
|
|
setUrl(r.seeUrl) |
|
|
|
} |
|
|
|
// onSuccess(response, file); |
|
|
|
}) |
|
|
|
.catch(onError); |
|
|
|
}; |
|
|
|
}); |
|
|
@@ -87,6 +92,8 @@ const EnterpriseLog = () => { |
|
|
|
}, |
|
|
|
}; |
|
|
|
}, |
|
|
|
//defaultFileList: props.location.query.values ? props.location.query.values : null |
|
|
|
|
|
|
|
}; |
|
|
|
return ( |
|
|
|
<div className={styles.baseView}> |
|
|
|