From b2c1ceb89fafc76f18ec650d19ec0ff03e4a20b0 Mon Sep 17 00:00:00 2001 From: Jonas L Date: Sun, 7 Jan 2024 15:07:01 +0100 Subject: [PATCH] fix(api): paths with question marks chars are handled by X-Accel-Redirect (#2875) Use the filepath_to_uri function instead. --- api/libretime_api/storage/views/file.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/libretime_api/storage/views/file.py b/api/libretime_api/storage/views/file.py index 25024fff4..fc59c5016 100644 --- a/api/libretime_api/storage/views/file.py +++ b/api/libretime_api/storage/views/file.py @@ -2,7 +2,7 @@ import os from django.http import HttpResponse from django.shortcuts import get_object_or_404 -from django.utils.encoding import iri_to_uri +from django.utils.encoding import filepath_to_uri from rest_framework import viewsets from rest_framework.decorators import action from rest_framework.serializers import IntegerField @@ -26,6 +26,6 @@ class FileViewSet(viewsets.ModelViewSet): # HTTP headers must be USASCII encoded, or Nginx might not find the file and # will return a 404. - redirect_uri = iri_to_uri(os.path.join("/api/_media", file.filepath)) + redirect_uri = filepath_to_uri(os.path.join("/api/_media", file.filepath)) response["X-Accel-Redirect"] = redirect_uri return response