Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top