diff options
| author | Collin Anderson <cmawebsite@gmail.com> | 2015-01-03 12:06:24 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-01-05 10:51:52 -0500 |
| commit | 3d2cae0896ee8026d1c2c5d31e4c4c8f74f2fef4 (patch) | |
| tree | 1abf00da86cd8831b829124a32058ea589b78b3c /docs/ref/request-response.txt | |
| parent | 05f702b94ca4ad77236a1e299270e8014def02e6 (diff) | |
Fixed #24072 -- Added FileResponse for streaming binary files.
Diffstat (limited to 'docs/ref/request-response.txt')
| -rw-r--r-- | docs/ref/request-response.txt | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/ref/request-response.txt b/docs/ref/request-response.txt index 3f4d371df5..1375ba10e5 100644 --- a/docs/ref/request-response.txt +++ b/docs/ref/request-response.txt @@ -998,3 +998,21 @@ Attributes .. attribute:: StreamingHttpResponse.streaming This is always ``True``. + +FileResponse objects +==================== + +.. versionadded:: 1.8 + +.. class:: FileResponse + +:class:`FileResponse` is a subclass of :class:`StreamingHttpResponse` optimized +for binary files. It uses `wsgi.file_wrapper`_ if provided by the wsgi server, +otherwise it streams the file out in small chunks. + +.. _wsgi.file_wrapper: https://www.python.org/dev/peps/pep-3333/#optional-platform-specific-file-handling + +``FileResponse`` expects a file open in binary mode like so:: + + >>> from django.http import FileResponse + >>> response = FileResponse(open('myfile.png', 'rb')) |
