DEV Community

Darcy
Darcy

Posted on • Updated on

Help! How to upload files to S3

Hey all :) I am struggling with something and wondering whether somebody could help me.

I am trying to upload files to S3. I have watched several tutorials on it and am still having trouble, specifically:

Whether to upload from server-side or client? For this project, the cost is a priority and based on this article I am learning toward uploading client side. Is that the correct approach?

Top comments (4)

Collapse
 
shravan20 profile image
Shravan Kumar B

The best approach would be storing the image from the Server side, rather than from the client side.
From the client side approach is not actually a good practice, as a lot of burden will be carried apart from client restrictions, you will have to handle all the cases from client side, which is a overhead.

Collapse
 
isotopeee profile image
isotopeee • Edited

It's okay to upload from the client-side and you can still secure it by using Presigned URLs (medium.com/@aidan.hallett/securing...), but you still have to create an endpoint that will be responsible for getting Presigned URLs from s3.

If you're open to using third-party libraries, try github.com/odysseyscience/react-s3... or react-dropzone-uploader.js.org/doc....

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

Using firebase +/- firebase-admin should also be easy, as it is designed to not need a backend.

Collapse
 
hcz1 profile image
Harry Zachariou

I would recommend, opening an API Gateway with lambda proxy, which you send the file to, which you can assign the correct permission policy to to upload to the S3 bucket.