Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get an object from S3 using it's pre-signed url in boto3?

I have generated a pre-signed url for an object in one of my buckets using boto3:

s3.generate_presigned_url('get_object', Params = {'Bucket': 'https://s3.amazonaws.com/<>', 'Key': '<>.json'}, ExpiresIn = 100)

Now, how do I get_object it in boto3? The boto3's get_object reference doesn't specify any argument for a pre-signed url.

So, how do I get that object from S3 using it's pre-signed url in boto3?

like image 717
Dawny33 Avatar asked Mar 10 '23 11:03

Dawny33


1 Answers

If you have a pre-signed URL, you don't need boto -- you can download the object using any HTTP user agent library.

Conversely, if you have boto and the credentials, you don't need a pre-signed URL.

Pre-signed URLs are intended for allowing someone with credentials to enable someone else without credentials to access a resource, without exposing the credentials to them.

A pre-signed URL includes the access-key-id and possibly a session-token, but not the access-key-secret, and are computationally-infeasible to reverse-engineer... and in this sense, they do not expose the credentials in a way that allows the entity possessing the pre-signed URL to use the associated credentials for any other purpose.

like image 90
Michael - sqlbot Avatar answered Apr 05 '23 23:04

Michael - sqlbot