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

merge-requests/154/head^2
Hazmo 2018-04-22 11:08:57 +00:00
rodzic 43e7555b09
commit 5879d2d655
1 zmienionych plików z 4 dodań i 1 usunięć

Wyświetl plik

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