question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ZIP file corrupted . Using Axios POST method .

See original GitHub issue

Hey 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:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
Alanscutcommented, Nov 13, 2019

try to config:

headers:{
           'Content-Type': 'application/json; application/octet-stream'
},
 responseType: 'blob'
0reactions
chinesedfancommented, Apr 19, 2020

Closed due to lack of enough information.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found