Update views.py to modify headers depending on Nginx or Apache

This commit is contained in:
Hazmo 2018-04-22 11:08:57 +00:00
parent 43e7555b09
commit 5879d2d655
1 changed files with 4 additions and 1 deletions

View File

@ -238,6 +238,9 @@ class TrackFileViewSet(viewsets.ReadOnlyModelViewSet):
f.serve_from_source_path) f.serve_from_source_path)
response = Response() response = Response()
filename = f.filename filename = f.filename
if settings.USE_APACHE_HEADERS:
response['X-Sendfile'] = file_path
else:
response['X-Accel-Redirect'] = file_path response['X-Accel-Redirect'] = file_path
filename = "filename*=UTF-8''{}".format( filename = "filename*=UTF-8''{}".format(
urllib.parse.quote(filename)) urllib.parse.quote(filename))