Setting it explicitly to, e.g. 'inline; filename="example.png"' in the
other case would allow the browser to set a default name for that inline
file in case a user attempts to download it with the 'Save image as...'
option.
That filename value is also visible in the title of the tab when image is
being viewed directly in Firefox (at least v56).
--
Ticket URL: <https://code.djangoproject.com/ticket/30196>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> FileResponse currently sets the Content-Disposition header only if
> as_attachment is true.
>
> Setting it explicitly to, e.g. 'inline; filename="example.png"' in the
> other case would allow the browser to set a default name for that inline
> file in case a user attempts to download it with the 'Save image as...'
> option.
>
> That filename value is also visible in the title of the tab when image is
> being viewed directly in Firefox (at least v56).
New description:
FileResponse currently sets the Content-Disposition header only if
as_attachment is true.
Setting it explicitly to, e.g. 'inline; filename="example.png"' in the
other case would allow the browser to set a default name for that inline
file in case a user attempts to download it with the 'Save image as...'
option.
That filename value is also visible in the title of the tab when image is
being viewed directly in Firefox (at least v56).
Created a pull request: https://github.com/django/django/pull/11011
--
--
Ticket URL: <https://code.djangoproject.com/ticket/30196#comment:1>
* needs_tests: 0 => 1
* stage: Unreviewed => Accepted
Comment:
The feature request makes sense but it's still missing tests.
--
Ticket URL: <https://code.djangoproject.com/ticket/30196#comment:2>
Comment (by Piotr Kunicki):
Sorry for ''beginner'' questions, but: as in, you want me to add some unit
tests?
No problem, but wouldn't a single test be enough?
All this change does, after all, is setting Content-Disposition when
as_attachment=False, so checking if it works shouldn't require more.
I also noticed there's no unit test checking if setting a custom filename
works, so i added it to the same one test.
What else to add?
--
Ticket URL: <https://code.djangoproject.com/ticket/30196#comment:3>
* needs_tests: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/30196#comment:4>
* needs_docs: 0 => 1
* easy: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/30196#comment:5>
* needs_docs: 1 => 0
Comment:
Added documentation changes to the commit in PR.
--
Ticket URL: <https://code.djangoproject.com/ticket/30196#comment:6>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/30196#comment:7>
* owner: nobody => Piotr Kunicki
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/30196#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"de4832c49b8a8cf00b2d602ab4d10c4ca69627bd" de4832c]:
{{{
#!CommitTicketReference repository=""
revision="de4832c49b8a8cf00b2d602ab4d10c4ca69627bd"
Fixed #30196 -- Made FileResponse set Content-Disposition inline if
filename is available.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30196#comment:9>