From 3d2cae0896ee8026d1c2c5d31e4c4c8f74f2fef4 Mon Sep 17 00:00:00 2001 From: Collin Anderson Date: Sat, 3 Jan 2015 12:06:24 -0500 Subject: Fixed #24072 -- Added FileResponse for streaming binary files. --- docs/ref/request-response.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'docs/ref') 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')) -- cgit v1.3