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

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

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

axios.post(url, postData, { responseType: 'blob',
        headers:{
            'Content-Type':"application/json",
            'x-correlation-id': 'EEBO-'+ uuidv4(),
            'x-source-id': 'EEBO',
            'x-source-country' : 'CN',
            'x-source-version': Constants.BO_VERSION,
            'x-source-date-time' :  FormatCurrentDateToISOFormat(),
            'x-acc-op' : jwt,
        }

     })
         .then(({ data }) =>  {
            console.log("gettoken",data);
            // data.auth = true;
            var fileURL = window.URL.createObjectURL(new Blob([data]));
            var fileLink = document.createElement('a');

            fileLink.href = fileURL;
            fileLink.setAttribute('download', 'AdminReport_'+current_date+'.zip');
            document.body.appendChild(fileLink);

            fileLink.click();

        })

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

暂无答案!

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

相关问题