使用react axios下载的zip文件在服务器中损坏

zvokhttg  于 2021-09-23  发布在  Java
关注(0)|答案(0)|浏览(414)

这是我用来下载zip文件的代码。

  1. axios.post(url, postData, { responseType: 'blob',
  2. headers:{
  3. 'Content-Type':"application/json",
  4. 'x-correlation-id': 'EEBO-'+ uuidv4(),
  5. 'x-source-id': 'EEBO',
  6. 'x-source-country' : 'CN',
  7. 'x-source-version': Constants.BO_VERSION,
  8. 'x-source-date-time' : FormatCurrentDateToISOFormat(),
  9. 'x-acc-op' : jwt,
  10. }
  11. })
  12. .then(({ data }) => {
  13. console.log("gettoken",data);
  14. // data.auth = true;
  15. var fileURL = window.URL.createObjectURL(new Blob([data]));
  16. var fileLink = document.createElement('a');
  17. fileLink.href = fileURL;
  18. fileLink.setAttribute('download', 'AdminReport_'+current_date+'.zip');
  19. document.body.appendChild(fileLink);
  20. fileLink.click();
  21. })

在我的机器中,它工作正常(能够下载并打开excel文件),不幸的是无法从服务器打开下载的zip文件(我们使用的是openshift)。
我可以在控制台中看到:在机器控制台中: gettoken Blob {size: 3809, type: "application/zip"} 服务器控制台: gettoken Blob {size: 3809, type: "text/html"} 我不知道怎么了,请帮帮我。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题