I try to generate a file, whose mime-type I don't know, to let the user download it via flask and it just creates a textfile.
Context: The user enters a Base64 encoded file, the site should decode it end let the user download this file.
Current state:
(decodedText is the decoded base64)
from flask import make_response
@app.route('/tools/base64', methods=['GET', 'POST'])
def base64():
response = make_response(decodedText)
response.headers["Content-Disposition"] = "attachment; filename=file"
response.headers["Content-Type"] = "application/octet-stream"
return response
The result of this is a textfile with content like
b'\xff\xd8\xff\xe0\x00\x10'
What I tried:
The "Content-Type"-Line is i.e. one line I found searching the internet, this should tell the browser that it's a binary - and firefox says now that it's a binary, but when downloaded it's still text... I also tried removing the b'', but I guess then it was explicit text.
So the question is: what do I need to tell python/flask so it's an actual binary file which will be downloaded?
Thank you very much in advance.