Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jovuit
funkwhale
Commits
4a5484c7
Verified
Commit
4a5484c7
authored
Oct 16, 2019
by
Eliot Berriot
Browse files
Fix audio serving issues under S3/nginx when signatures are enabled
parent
8de30049
Changes
3
Hide whitespace changes
Inline
Side-by-side
api/funkwhale_api/music/views.py
View file @
4a5484c7
...
...
@@ -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
)
...
...
api/tests/music/test_views.py
View file @
4a5484c7
...
...
@@ -247,6 +247,18 @@ def test_serve_file_in_place_nginx_encode_url(
assert
response
[
"X-Accel-Redirect"
]
==
expected
def
test_serve_s3_nginx_encode_url
(
mocker
,
settings
):
settings
.
PROTECT_FILE_PATH
=
"/_protected/media"
settings
.
REVERSE_PROXY_TYPE
=
"nginx"
audio_file
=
mocker
.
Mock
(
url
=
"https://s3.storage.example/path/to/mp3?aws=signature"
)
expected
=
(
b
"/_protected/media/https://s3.storage.example/path/to/mp3%3Faws%3Dsignature"
)
assert
views
.
get_file_path
(
audio_file
)
==
expected
@
pytest
.
mark
.
parametrize
(
"proxy,serve_path,expected"
,
[
...
...
changes/changelog.d/s3-proxy.bugfix
0 → 100644
View file @
4a5484c7
Fix audio serving issues under S3/nginx when signatures are enabled
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment