File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,23 @@ def _serve_401(request, project):
139
139
140
140
141
141
def _serve_file (request , filename , basepath ):
142
+ """
143
+ Serve media file via Django or NGINX based on ``PYTHON_MEDIA``.
144
+
145
+ When using ``PYTHON_MEDIA=True`` (or when ``DEBUG=True``) the file is served
146
+ by ``django.views.static.serve`` function.
147
+
148
+ On the other hand, when ``PYTHON_MEDIA=False`` the file is served by using
149
+ ``X-Accel-Redirect`` header for NGINX to take care of it and serve the file.
150
+
151
+ :param request: Django HTTP request
152
+ :param filename: path to the filename to be served relative to ``basepath``
153
+ :param basepath: base path to prepend to the filename
154
+
155
+ :returns: Django HTTP response object
156
+
157
+ :raises: ``Http404`` on ``UnicodeEncodeError``
158
+ """
142
159
# Serve the file from the proper location
143
160
if settings .DEBUG or getattr (settings , 'PYTHON_MEDIA' , False ):
144
161
# Serve from Python
You can’t perform that action at this time.
0 commit comments