简体   繁体   中英

Unable to download zip file using axios

This is the code I use:

axios.get(fileUrl, {headers:{'X-API-TOKEN':xxxxxx})

Response data received is in binary, Which I am converting to base64 and saving in file. After saving zip file. If I try to open the file, it says invalid zip error.

You can try adding responseType as arraybuffer

axios.get(
   fileUrl,
   {headers:{'X-API-TOKEN':xxxxx}, responseType: 'arraybuffer'}
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM