Thu Sep 30 2021·2 min read
Photo by Andrew Ly
To get an S3 presigned URL using the AWS CLI, invoke the
aws s3 presign s3://my-bucket/file.txt command, where you specify the entire
path of the object in the S3 URI.
aws s3 presign s3://YOUR_BUCKET/your-file.txt
By default the presigned url is valid for
3600 seconds, which is
If you click on the URL, you will see the contents of the file in your browser.
To configure when the presigned url should expire, use the
parameter. It allows us to specify the number of seconds the presigned url
should be valid for.
aws s3 presign s3://YOUR_BUCKET/your-file.txt --expires-in 10
In the example above, the presigned URL will only be valid for 10 seconds. If
the url is accessed after 10 seconds, it returns an
Note that the
command only generates
GET presigned urls, if you want to upload files to an
S3 bucket using
PUT presigned urls, you have to use the AWS SDK.
To learn more about uploading files to an S3 bucket, using presigned urls, check out my other articles:
I'll send you 1 email a week with links to all of the articles I've written that week