diff options
author | Andy Doan <andy.doan@linaro.org> | 2017-05-01 12:44:18 -0500 |
---|---|---|
committer | Fathi Boudra <fathi.boudra@linaro.org> | 2017-05-02 07:15:44 +0000 |
commit | 755ed89d90516eb5511a74649ca99fd04b5ae309 (patch) | |
tree | faf124674b8246b4b3e97da55c1ce3f56d4c2660 /license_protected_downloads/api/v3.py | |
parent | 5c9407fbda4c2e5fffe07c50b2720f1898df4db2 (diff) |
fix s3 urlencoded paths
We have some publishing jobs that are now naming files with ~'s in them.
The problem is that the tilde has to be converted to %7E so that its a
safe url-encoded string for S3 to sign. This leaves us calling the file
2 different things which S3 won't allow when trying to upload to the
signed url.
The safe way to handle this is to store all S3 files with urlencoded
names. We then modify our presentation layer to decode that name so its
listed sanely.
Change-Id: I782de89b25776d55ed03afa882245e0d01c5216b
Reviewed-on: https://review.linaro.org/19091
Reviewed-by: Ben Copeland <ben.copeland@linaro.org>
Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org>
Diffstat (limited to 'license_protected_downloads/api/v3.py')
-rw-r--r-- | license_protected_downloads/api/v3.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/license_protected_downloads/api/v3.py b/license_protected_downloads/api/v3.py index b43f10b..9ef6470 100644 --- a/license_protected_downloads/api/v3.py +++ b/license_protected_downloads/api/v3.py @@ -1,4 +1,5 @@ import os +import urllib from django.conf import settings from django.http import HttpResponse @@ -27,7 +28,8 @@ class PublishResource(v2.PublishResource): if not b: raise HttpResponseError('S3 is not enabled', 403) - k = b.new_key(settings.S3_PREFIX_PATH + self.path) + path = urllib.pathname2url(self.path) + k = b.new_key(settings.S3_PREFIX_PATH + path) if k.exists(): APILog.mark(self.request, 'FILE_OVERWRITE_DENIED') raise HttpResponseError('File already exists', 403) |