Reputation: 53920
I have a static folder that is managed by apache where images are stored. I wonder if it's possible by configuring apache to send all files from that folder as downloadable files, not opening them as images inside browser? I suppose I can do it by creating a special view in Flask, but I think it would be nicer if I could do it with some more simple solution.
Upvotes: 4
Views: 236
Reputation: 9522
flask.send_from_directory
with as_attachment=True
argument can do this.
Also, you can configure Apache to send Content-Disposition: attachment
header like in this answer
Upvotes: 3
Reputation: 7763
You can force the contents to be a downloadable attachment using http headers.
In PHP that would be:
$fileName = 'dummy.jpg';
header("Content-Disposition: attachment; filename=$fileName");
Then, the script dumps the raw contents of the file.
Upvotes: 1