aboutsummaryrefslogtreecommitdiff
path: root/license_protected_downloads/artifact/s3.py
diff options
context:
space:
mode:
authorAndy Doan <andy.doan@linaro.org>2017-05-01 12:44:18 -0500
committerFathi Boudra <fathi.boudra@linaro.org>2017-05-02 07:15:44 +0000
commit755ed89d90516eb5511a74649ca99fd04b5ae309 (patch)
treefaf124674b8246b4b3e97da55c1ce3f56d4c2660 /license_protected_downloads/artifact/s3.py
parent5c9407fbda4c2e5fffe07c50b2720f1898df4db2 (diff)
downloadlinaro-license-protection-755ed89d90516eb5511a74649ca99fd04b5ae309.tar.gz
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/artifact/s3.py')
-rw-r--r--license_protected_downloads/artifact/s3.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/license_protected_downloads/artifact/s3.py b/license_protected_downloads/artifact/s3.py
index e7f8282..0ba0cca 100644
--- a/license_protected_downloads/artifact/s3.py
+++ b/license_protected_downloads/artifact/s3.py
@@ -1,6 +1,7 @@
import datetime
import mimetypes
import os
+import urllib
import time
import boto
@@ -50,6 +51,7 @@ class S3Artifact(Artifact):
file_name = ''
item.size = 0
item.last_modified = '-'
+ file_name = urllib.url2pathname(file_name)
self.bucket = bucket
self.parent = parent
if parent and hasattr(self.parent, 'children'):
@@ -128,7 +130,7 @@ class S3Artifact(Artifact):
else:
key += '/' + os.path.dirname(self.file_name) + fname
try:
- key = boto.s3.key.Key(self.bucket, key)
+ key = boto.s3.key.Key(self.bucket, urllib.pathname2url(key))
return key.get_contents_as_string()
except boto.exception.S3ResponseError:
pass # return None - its okay