How to generate temporary URL to upload files to S3 using boto

0 votes

I tried uploading files using: key.generate_url(3600, method='PUT') but it says request signature does not match the signature you provided.

Please help me with this

Jul 27, 2018 in Cloud Computing by code_ninja
• 6,290 points
1,174 views

1 answer to this question.

0 votes

Use the following code to do so:

import boto
>>> c =boto.connect_s3()
>>> fp = open('myfiletoupload.txt')
>>> content_length = len(fp.read())
>>> c.generate_url(300, 'PUT', 'test-1332789015', 'foobar', headers={'Content-Length': str(content_length)}, force_http=True)
'http://test-1332789015.s3.amazonaws.com/foobar?Signature=oUARG45mR95utXsiQYRJNiCI4x4%3D&Expires=1333731456&AWSAccessKeyId=AKIAJOTCCJRP4C3NSMYA&Content-Length=16'


Then use curl to PUT the file to that URL
$ curl --request PUT --upload-file myfiletoupload.txt "http://test-1332789015.s3.amazonaws.com/foobar?Signature=oUARG45mR95utXsiQYRJNiCI4x4%3D&Expires=1333731456&AWSAccessKeyId=AKIAJOTCCJRP4C3NSMYA&Content-Length=16"


Thank you in advance
answered Jul 27, 2018 by Gopalan
• 1,360 points

Related Questions In Cloud Computing

+4 votes
2 answers

Amazon S3 Permission problem - How to set permissions for all files at once?

This can be done by setting the ...READ MORE

answered Mar 27, 2018 in Cloud Computing by brat_1
• 7,200 points
3,519 views
+1 vote
1 answer

Can we use boto to generate last modified datetime of S3 objects

Okay this code snippet will help you ...READ MORE

answered Apr 10, 2018 in Cloud Computing by hemant
• 5,790 points
5,366 views
+1 vote
3 answers

How to upload files on aws elastic beanstalk?

yes once you store it in (AWS) ...READ MORE

answered Sep 3, 2018 in Cloud Computing by bug_seeker
• 15,520 points
6,289 views
+4 votes
2 answers

How come AWS S3 is erasing my extension from PDF files?

I think the problem should be with ...READ MORE

answered Mar 27, 2018 in Cloud Computing by code_ninja
• 6,290 points
3,629 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to delete the files from AWS S3 except the recently 5 added/updated files?

Use AWS s3 rm command with multiple --exclude options as shown: aws ...READ MORE

answered Jul 30, 2018 in Cloud Computing by Gopalan
• 1,360 points
3,553 views
+7 votes
3 answers

How to download folder from AWS S3?

To Download using AWS S3 CLI : aws ...READ MORE

answered Sep 7, 2018 in Cloud Computing by eatcodesleeprepeat
• 4,710 points
275,333 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP