Commits

Anonymous committed dceb0e0

fixing quote_plus unicode problem.

Comments (0)

Files changed (1)

 METADATA_PREFIX = 'x-amz-meta-'
 AMAZON_HEADER_PREFIX = 'x-amz-'
 
+# tommy change to solve latin characters problem with s3
+def prepare_key(key):
+    return urllib.quote_plus(key.encode('utf-8'))
+
 # generates the aws canonical string for the given parameters
 def canonical_string(method, bucket="", key="", query_args={}, headers={}, expires=None):
     interesting_headers = {}
         buf += "/%s" % bucket
 
     # add the key.  even if it doesn't exist, add the slash
-    buf += "/%s" % urllib.quote_plus(key)
+    buf += "/%s" % prepare_key(key)
 
     # handle special query string arguments
 
 
         # add the slash after the bucket regardless
         # the key will be appended if it is non-empty
-        path += "/%s" % urllib.quote_plus(key)
+        path += "/%s" % prepare_key(key)
 
 
         # build the path_argument string
 
         url = CallingFormat.build_url_base(self.protocol, self.server, self.port, bucket, self.calling_format)
 
-        url += "/%s" % urllib.quote_plus(key)
+        url += "/%s" % prepare_key(key)
 
         query_args['Signature'] = encoded_canonical
         query_args['Expires'] = expires