Skip to content

Creating a pre-signed url directly from my website

0

Hi...

Forgive me ahead of time, but I'm very new to this. I currently have an small website used to archive documents / images etc and all the data is stored on S3 storage. I would like to have an generate link button on my site so that users can create a pre-signed url with access to that object for a limited time. I have already restricted access to the website so only a few people have access to it but I would like them to have a pre-signed link to enable them to pass it on to their individual teams. Can anyone suggest the best way of doing this?

It would also be useful at this stage of my understanding of S3 storage if you answered as though I had the brains of a Golden Retriever...

Thank you in advance

Colin.

  • 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.

asked 10 months ago1.1K views
1 Answer
1

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:

  1. User clicks "Generate Link" button on your website.
  2. Your website sends a request to your server.
  3. Your server uses AWS SDK to create a pre-signed URL for the specified object.
  4. The server sends the URL back to your website.
  5. 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

answered 10 months ago
EXPERT
reviewed 9 months ago
EXPERT
reviewed 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.