Skip to content
Advertisement

How do I get a download link for an object I upload to an AWS bucket?

I’m using AWS S3 boto3 to upload files to my AWS bucket called uploadtesting. Here is an example implementation:

JavaScript

Accessing the object from the AWS S3 console allows you to see the object URL, however it is not a downloadable link. What I wanted to know is how can I use python to print out a downloadable link to the file I just uploaded?

Advertisement

Answer

It appears you are asking how to generate a URL that allows a private object to be downloaded.

This can be done by generating an Amazon S3 pre-signed URL, which provides access to a private S3 object for a limited time.

Basically, using credentials that have access to the object, you can create a URL that is ‘signed’. When Amazon S3 receives this URL, it verifies the signature and provides access to the object if the expiry period has not ended.

From Presigned URLs — Boto3 documentation:

JavaScript

The ExpiresIn parameter is expressed in seconds.

Advertisement