I am trying to download a zipfile that my webapp receives my backend in javascript. I am using the file-saver library, just because I use it in another part of the app, but I would also be ok, doing it with vanilla js (creating a blob, attaching it to hidden a element...). I tried out all I could find on the web about it, but it still doesn't work. The file is downloaded, but it cannot be opened, my archive manager just says there is an error... However, I know that the file coming from the server is ok. When test the endpoint of the api, that delivers the file, in swagger I can download and open the file normally.
if (response.headers["content-type"] === "application/zip") {
const filename = response.headers['Content-Disposition'].match(/filename="(.+)"/)[1]
FileSaver.saveAs(new Blob([response.data], {type: "application/zip"}), filename)
}
If anyone has any tip, on how I could go about debugging this, I would be very thankful :)
Santiago Gelvez