Hey everyone! I'm looking for some advice on adding file upload functionality to my website. Currently, users can log in, but we don't have any way for them to upload files. I have a couple of options in mind using AWS S3. Option 1 is a direct upload approach where the backend handles everything, and the S3 bucket isn't public. Option 2 involves using AWS pre-signed URLs, which would allow uploads directly from the browser to S3, possibly resulting in faster uploads and less load on the backend. However, I've heard that Option 2 could be trickier to implement. I'm just looking for thoughts on which option might be better, including the pros and cons of each. Thanks for your help!
4 Answers
Going with pre-signed URLs is the smarter move here. They offer a good balance of security and performance, making them a popular choice among developers.
If you're leaning toward Option 2, here's how it generally works: your frontend sends some parameters to a backend endpoint that uses AWS libraries to generate a pre-signed URL. The frontend then takes that URL and uploads the file directly to S3. This can introduce some complexity, but it’s often worth it for the performance gains and security.
I definitely recommend Option 2! It keeps your S3 bucket secure and your server free from heavy file load. Plus, there are some great libraries to help you manage this, like Uppy. Check it out for some client-side support!
Yes, Uppy is fantastic for handling uploads efficiently!
Option 2 is the best choice in most situations. It reduces backend processing and keeps your bucket private. Just ensure you handle validations correctly on your server side to keep everything secure.
Totally agree! Pre-signed URLs are the way to go for most cases.