Fixed #30694 -- Documented FileResponse does not seek its file source.
This commit is contained in:
parent
6805c0f99f
commit
7203efb799
|
@ -67,6 +67,7 @@ Here's a "Hello World" example::
|
||||||
|
|
||||||
# FileResponse sets the Content-Disposition header so that browsers
|
# FileResponse sets the Content-Disposition header so that browsers
|
||||||
# present the option to save the file.
|
# present the option to save the file.
|
||||||
|
buffer.seek(0)
|
||||||
return FileResponse(buffer, as_attachment=True, filename='hello.pdf')
|
return FileResponse(buffer, as_attachment=True, filename='hello.pdf')
|
||||||
|
|
||||||
The code and comments should be self-explanatory, but a few things deserve a
|
The code and comments should be self-explanatory, but a few things deserve a
|
||||||
|
|
|
@ -1122,6 +1122,8 @@ Attributes
|
||||||
|
|
||||||
If ``open_file`` doesn't have a name or if the name of ``open_file`` isn't
|
If ``open_file`` doesn't have a name or if the name of ``open_file`` isn't
|
||||||
appropriate, provide a custom file name using the ``filename`` parameter.
|
appropriate, provide a custom file name using the ``filename`` parameter.
|
||||||
|
Note that if you pass a file-like object like ``io.BytesIO``, it's your
|
||||||
|
task to ``seek()`` it before passing it to ``FileResponse``.
|
||||||
|
|
||||||
The ``Content-Length`` and ``Content-Type`` headers are automatically set
|
The ``Content-Length`` and ``Content-Type`` headers are automatically set
|
||||||
when they can be guessed from contents of ``open_file``.
|
when they can be guessed from contents of ``open_file``.
|
||||||
|
|
Loading…
Reference in New Issue