jazzband / django-downloadview

Serve files with Django.
https://django-downloadview.readthedocs.io
Other
374 stars 57 forks source link

Set Content-Disposition for non-attachments #139

Open dalberto opened 7 years ago

dalberto commented 7 years ago

Currently, the Content-Disposition header is only set for attachments. It would be helpful to set the Content-Disposition with a filename value for non-attachments, even though it shouldn't include attachment in the header value. This would be useful if a user decides to save a file after viewing it. It is also useful if the file in question is not supported for inline viewing in the user's browser because the browser would then have a file name to use for saving.

I believe the simplest way of doing this is as follows:

Add an attachment argument to the django_downloadview.response.content_disposition function. In content_disposition check the value of attachment and conditionally add attachment to the header value. Update calls to content_disposition to include the attachment argument in:

Natim commented 4 years ago

Hello @dalberto could you file a pull-request with this feature if you still need it?