peterknife / boto

Automatically exported from code.google.com/p/boto
0 stars 0 forks source link

Error signing multipart upload request #477

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Initiate multipart upload request using rest api 
http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?mpUploadInitiat
e.html, using boto.connection.AWSAuthConnection.make_request
2. Observe that request is not signed properly

Making request:
s3_conn.make_request('POST', bucket, 'foo', query_args='uploads').read()

results in error :
'<?xml version="1.0" 
encoding="UTF-8"?>\n<Error><Code>SignatureDoesNotMatch</Code><Message>The 
request signature we calculated does not match the signature you provided. 
Check your key and signing method.</Message>
...
<StringToSign>POST\n\n\nThu, 18 Nov 2010 13:07:36 GMT\n/{ skip 
}/foo?uploads</StringToSign>

It turns out that boto does not include params after ? (except some exceptions, 
but "uploads" is not one of them).

A little path (against boto v1.9 (r1485)) helps (revisions are intern:

Index: boto/utils.py
===================================================================
--- boto/utils.py   
+++ boto/utils.py   
@@ -100,7 +100,7 @@
     # don't include anything after the first ? in the resource...
     buf += "%s" % path.split('?')[0]

-    # ...unless there is an acl or torrent parameter
+    # ...unless there is an acl or torrent or uploads parameter
     if re.search("[&?]acl($|=|&)", path):
         buf += "?acl"
     elif re.search("[&?]logging($|=|&)", path):
@@ -111,6 +111,8 @@
         buf += "?location"
     elif re.search("[&?]requestPayment($|=|&)", path):
         buf += "?requestPayment"
+    elif re.search("[&?]uploads($|=|&)", path):
+        buf += "?uploads"

     return buf

Using boto v1.9 (r1485) with python 2.6 and ubuntu 10.04

Original issue reported on code.google.com by kostia.l...@gmail.com on 18 Nov 2010 at 1:26

GoogleCodeExporter commented 9 years ago
it turns out that other requests, conserned with multipart uploads, also 
require full query string signing. But maybe I am just doing something wrong 
here

Original comment by kostia.l...@gmail.com on 18 Nov 2010 at 1:32

GoogleCodeExporter commented 9 years ago
I haven't actually added support for the multipart upload to the S3 code yet.  
It's on my short list.  Contributions are, of course, welcome!

Original comment by Mitch.Ga...@gmail.com on 18 Nov 2010 at 7:11

GoogleCodeExporter commented 9 years ago
Ok! I will implement it anyway, and how is it better to contribute? There are 
two separate areas: fixing signing of request and then parsing answers from the 
REST API, do want to include the second part as well?

Original comment by kostia.l...@gmail.com on 19 Nov 2010 at 9:40

GoogleCodeExporter commented 9 years ago
This is now fixed in:

https://github.com/boto/boto/commit/3ef0a37084231a4417a6cc93322d4b5a5cf118fa

Original comment by Mitch.Ga...@gmail.com on 6 Dec 2010 at 2:42