Merge branch 's3-proxy-fails-on-nginx' into 'master'

S3 proxy fails on nginx

See merge request funkwhale/funkwhale!935
This commit is contained in:
Eliot Berriot 2019-10-17 10:21:59 +02:00
commit 109c490639
3 changed files with 17 additions and 0 deletions

View file

@ -320,6 +320,10 @@ def get_file_path(audio_file):
)
path = "/music" + audio_file.replace(prefix, "", 1)
if path.startswith("http://") or path.startswith("https://"):
protocol, remainder = path.split("://", 1)
hostname, r_path = remainder.split("/", 1)
r_path = urllib.parse.quote(r_path)
path = protocol + "://" + hostname + "/" + r_path
return (settings.PROTECT_FILES_PATH + "/media/" + path).encode("utf-8")
# needed to serve files with % or ? chars
path = urllib.parse.quote(path)