I have a zip file in my server, and I want to create a download button for the user, heres my flask code:
@app.route("/profile", methods=["GET", "POST"])
def profile():
if request.method == "GET":
return render_template("profile.html")
if request.method == "POST":
#Some code
return send_file(f"user_projects/delivery.zip")
And here's my JS code:
xhr.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
if (something) {
some code
}
else {
var zipFile = new Blob([this.response])
var url = URL.createObjectURL(zipFile)
downloadLink.href = url;
}
}
}
When I click the "a" element (downloadLink) I can download the zip file, but when I try to open it I get an error saying:
ERRORS: Is not archive WARNINGS: Headers Error
The zip file from the server is 100% fine, I can open it without any problem, the issue is when I download it from my website so I think there is something I am taking for granted. Any help is appreciated, thanks.