I am currently trying to build a webservice to generate temporary URLs to Amazon S3 (so that I don't need to keep the credentials elsewhere). It works fine if I do not include the 'Content-MD5' key to the header for the generate_url method, but once included, I always get the same error :
"The request signature we calculated does not match the signature you provided. Check your key and signing method."
The md5 is generated and included in the following way :
md5checksum = key.compute_md5(open(filepath, "rb"))[0]
r = cli.session.post(serviceAddress + webService , data=json.dumps({"key": key, "size": os.path.getsize(filepath), "md5" : md5checksum}))
I have also tried generating the md5 with
md5checksum = hashlib.md5(open(filepath).read()).hexdigest()
On the webservice's side, the temporary URL is generated via
headers={'Content-Length': length, 'Content-MD5': md5}
return self.conn.generate_url(expire, 'PUT', self.name, key, headers=headers, force_http=True)
I have checked that the md5 does not change between the generation of the URL and the file's upload. If I just remove 'Content-MD5': md5, it does work fine.
Aucun commentaire:
Enregistrer un commentaire