mirror of
https://github.com/daniviga/django-ram.git
synced 2026-02-27 21:22:27 +01:00
Fix X-Accel-Redirect with non-ASCII names
This commit is contained in:
@@ -17,7 +17,7 @@ from django.http import (
|
|||||||
)
|
)
|
||||||
from django.views import View
|
from django.views import View
|
||||||
from django.utils.text import slugify as slugify
|
from django.utils.text import slugify as slugify
|
||||||
from django.utils.encoding import smart_str
|
from django.utils.encoding import iri_to_uri, smart_str
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
|
||||||
@@ -112,7 +112,9 @@ class DownloadFile(View):
|
|||||||
if getattr(settings, "USE_X_ACCEL_REDIRECT", False):
|
if getattr(settings, "USE_X_ACCEL_REDIRECT", False):
|
||||||
response = HttpResponse()
|
response = HttpResponse()
|
||||||
response["Content-Type"] = ""
|
response["Content-Type"] = ""
|
||||||
response["X-Accel-Redirect"] = f"/private/{file.name}"
|
response["X-Accel-Redirect"] = iri_to_uri(
|
||||||
|
f"/private/{file.name}"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
response = FileResponse(
|
response = FileResponse(
|
||||||
open(file.path, "rb"), as_attachment=True
|
open(file.path, "rb"), as_attachment=True
|
||||||
|
|||||||
Reference in New Issue
Block a user