How to create S3 links?
There are a few ways you can create private links on AWS S3. Which one is best depends on your use case and what you are trying to achieve. In this guide we will follow through those different techniques from which you can create those links and download data stored in your buckets:
Method 1: Private link via pre-signed URL
This method relies on the AWS SDK and requires to either:
- call the GeneratePreSignedURL function from the AWS SDK using your favourite programming language
- using the AWS CLI command line tool like this:
By default, those links will be valid for 1 hour but you can change the lifetime of the generated links with the
--expires-in flag. That’s one of the major drawbacks of this method, the generated links are time-limited, can only relate to a single file, isn’t very good looking and will require custom code if you want to create password-protected links or restrict those to certain users only.
Method 2: Public bucket with encryption
S3 has an option to make some objects public:
Once enabled you can access those from a link that looks like this: https://bucketname.s3.amazonaws.com/path/file.txt
If making your data available publicly isn’t ok, you can leverage the encryption feature in AWS.
Method 3: Using a third-party software
This method isn’t officially supported by Amazon but provides its users with the most flexibility. Indeed, third party software like Filestash makes it easy to create a shared link on S3 as easily as if you were on Dropbox:
Shared links can be a lot more granular with features to protect your data with a password, restrict access to certain users, expiration and access right without requiring your users to know about the intricacies of AWS S3 and without custom code. Try it now