H K
H K

Reputation: 57

how to make my users access to their own bucket in my application

I'm thinking to make my user access to their own s3 bucket so they can load and display their image in my web application.

user come to my web -> click UI -> login and auth -> select images -> display it.

Is this scenario possible? how? I'm using react for my front-end and node.js for my backend..

Do I use any file trasnfer protocol? or how to bring image from s3 bucket?

Upvotes: 1

Views: 189

Answers (2)

Chris Williams
Chris Williams

Reputation: 35188

If you're using JavaScript in your frontend and node js in your backend you will need to use the AWS JS SDK with the AWS.S3 class to perform all interactions.

You should look at storing the assets with a prefix of the username to make it easier to list objects (rather than image.jpg you would store at username/image.jpg).

To upload you would make use of the PutObject function, with the ListObjectsV2 function to list passing in the prefix.

You can further enhance this by using a Cognito User Pool to manage the authentication. You can enhance the security by making use of the ${cognito-identity.amazonaws.com:sub} variable in your IAM policy to restrict access to only the users specific prefix in S3.

Upvotes: 1

osanger
osanger

Reputation: 2352

You can use AWS Cognito fur the authentication part.

The easiest way to archive what you want is to use AWS amplify. See here Follow this guide for step by step instructions for node.js

Upvotes: 0

Related Questions