I want to make a service that is supposed to upload Photos in S3 and make them available using a link.

I have few design plans for my service.


Upload photo to my REST API which will update details like id, size, type, etc in a db table and upload file in S3 before updating in db. The db table will have s3 link to file. I am using a table for more requirements like attaching thumbnails which are processed and updated after the photo is uploaded, asynchronously.

Get Photo API will provide s3 bucket file link in response.

Plan 2:

Upload photo directly to S3 bucket and then make a rest API call to update db with photo details.

Get Photo API will provide s3 bucket file link in response.

What should be a suitable approach? Suggestion are welcome even if it doesn't belong to either of the above two but totally new idea.


Option 1. Always Option 1.

Why? Because the only way to directly upload something to S3 is via the AWS APIs and to use the AWS APIs you need an AWS key - and you should never distribute your AWS keys to your end users.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.