- Newest
- Most votes
- Most comments
Certainly, Colin! I'll explain how to create a pre-signed URL for your S3 objects directly from your website in simple terms.
First, it's great that you're already using S3 to store your documents and images, and that you've restricted access to your website. Now, let's talk about how to create those pre-signed URLs.
A pre-signed URL is like a special, temporary pass to access a specific object in your S3 bucket. It's perfect for sharing files with people who don't have AWS credentials.
To create a pre-signed URL from your website, you'll need to set up a server-side component. This could be a simple API endpoint on your web server. When a user clicks the "Generate Link" button on your website, it would trigger a request to this API.
On the server side, you'll use AWS SDK (Software Development Kit) to generate the pre-signed URL. The SDK has built-in functions to create these URLs easily. You'll need to specify which object you want to share and how long the link should be valid (expiration time).
Here's a general flow of how it would work:
- User clicks "Generate Link" button on your website.
- Your website sends a request to your server.
- Your server uses AWS SDK to create a pre-signed URL for the specified object.
- The server sends the URL back to your website.
- Your website displays the URL to the user, who can then share it.
When setting this up, you'll need to decide how long you want these links to be valid. The maximum time is 7 days when using AWS SDKs.
Remember, anyone with this pre-signed URL will be able to access the object, so be cautious about how long you make them valid and who you share them with.
To implement this, you'll need some programming knowledge or the help of a developer. They would set up the server-side component and integrate it with your website.
I hope this explanation helps you understand the process better, Colin. Remember, while it might seem complex at first, it's a powerful feature that can make sharing your S3 objects much easier and more secure.
Sources
Sharing objects with presigned URLs - Amazon Simple Storage Service
Uploading objects with presigned URLs - Amazon Simple Storage Service
Relevant content
- asked 2 years ago
- asked 14 days ago
- asked 5 months ago
you are saying you already restricted access to your site... How did you do this? With Amazon Cognito and Identity Pools (https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-identity.html) you could directly create the URL from the browser through the javascript sdk if the user has the proper permissions. An alternative would be to create the presigned URL at the backend side (e.g. via an Amazon API-Gateway and AWS Lambda)
Might also be worth having a look at AWS Amplify (https://aws.amazon.com/amplify/) which can help you with full stack development on AWS.