Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Content-Disposition for non-attachments #139

Open
dalberto opened this issue May 10, 2017 · 1 comment
Open

Set Content-Disposition for non-attachments #139

dalberto opened this issue May 10, 2017 · 1 comment

Comments

@dalberto
Copy link

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:

  • django_downloadview.response.DownloadResponse#default_headers
  • django_downloadview.apache.response.XSendfileResponse#__init__
  • django_downloadview.nginx.response.XAccelRedirectResponse#__init__
  • django_downloadview.lighttpd.response.XSendfileResponse#__init__
@Natim
Copy link
Collaborator

Natim commented Jan 7, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants