I'm trying to upload a server build to a URL retrieved via GetServerBuildUploadUrl(). The retrieved URL seems valid, but I'm having issues uploading to it. I've written the following Python script to attempt this:
The retrieved URL, stored in the script as 'upload_url', is for example:
with #### being the title ID of our game on PlayFab. I'm trying to upload a file directly to that URL, assuming that any authentication is already handled via the URL. Is that assumption correct?
I'm getting a 403 from Amazon with the error message 'The request signature we calculated does not match the signature you provided. Check your key and signing method.'
I should note that I'm not that familiar with HTTP requests nor Python, so I'm hoping anyone can point out something I'm blatantly doing wrong. :) We're using Jenkins, so if there is a more recommended way to automate the uploading of server builds from Jenkins I'd be happy to hear it too.
Answer by Zhi Kang Shao · Feb 16, 2017 at 01:15 PM
Although that gave the same 403 error, it did put me in the right direction. I wasn't using the right syntax for specifying the upload type (in the body instead of the header). This next snippet worked:
headers = { 'Content-Type': 'application/x-zip-compressed' } with open('TestFile.zip', 'rb') as data: r = put(upload_url, data=data, headers=headers)
Thanks for the help!
Answer by Brendan · Feb 15, 2017 at 08:41 PM
We use pre-signed URLs for S3 uploads, for security. Unfortunately, the requests post method in your code is attempting to do a multi-part file upload against that, which isn't going to work. Could you try this?
with open('TestFile.zip', 'rb') as data: requests.put(upload_url, data=data)