[Answered ]-Return a downloadable file link given a string with Django

2👍

Use the X-Accel-Redirect header: http://wiki.nginx.org/XSendfile

For example:

resp = HttpResponse()
resp['X-Accel-Redirect'] = "/static/my_file"
return resp

Note that, as per the documentation, you’ll need to translate the local path into a URL which nginx can serve.

Leave a comment