I'm trying to create an API endpoint that accepts several files (that's why I need POST request, not GET request) and responds with another file. I want browser to present a "save as..." dialog (or just start downloading).
Here's a demo code that doesn't work (Flask):
@app.route('/api', methods=['POST'])
def api():
return send_file('./sample.txt', as_attachment=True)
I can see proper response headers, but nothing happens in the browser:
HTTP/1.0 200 OK
Content-Disposition: attachment; filename=sample.txt
Content-Length: 612
Content-Type: text/plain; charset=utf-8
If I remove methods=['POST']
from endpoint and issue a GET request to it, it works fine, the browser asks if I want to save this file.
What am I doing wrong or it's just how things are (Content-Disposition ignored for POST responses?)