ZIP file corrupted . Using Axios POST method .
See original GitHub issueHey guys , I think that i am doing something wrong , but when i click on my button i get an zip file , but it says that is corrupted when i try to open it . What am i doing wrong ?
`getZip = () => {
let postZipData = {
customerNumber: this.state.customerNumber,
docList: this.state.docList,
}
const token = localStorage.getItem('token');
const axiosConfig = {
responseType: 'arraybuffer',
header: {
'Content-Type': 'multipart/form-data',
'Access-Control-Allow-Origin': '*',
'Authorization': 'Bearer ' + token
}
};
axios.post(SERVER_URL + '/api/user/bills/zip', postZipData, axiosConfig)
.then((response) => {
const url = new Blob([response.data],{
type:'application/zip'
});
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.zip');
document.body.appendChild(link);
link.click();
})
console.log('get the zip')
}`
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Zip File downloaded from ReactJs/Axios is corrupted
I am able to successfully download and unzip the file using that. Here is my code fragment: axios .post('http://0.0.0.0:8000/sheets/', ...
Read more >Zip File downloaded from ReactJs/Axios is corrupted - iTecNote
I'm trying to download a zip file from a Django api and have the user download it. There are two .csv files in...
Read more >Zip File downloaded using ReactJs/Axios is corrupted - Reddit
Using React/Axios. I am trying to download a zip file from a Django API. The zip file is always corrupted when I try...
Read more >Zip file corrupted when downloading in React and NodeJs
I have an application in React and NodeJS. React makes a post to node with an id and node makes a get to...
Read more >Download ZIP File via Axios Post - Laracasts
Hi, Im coming into some trouble trying to work out how to download a zip file via an axios post request. Currently the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
try to config:
Closed due to lack of enough information.