Hi everyone, I have to implement image upload for my project and it will mostly be user profile and company profile images. I checked out examples and was thinking about using the s3 example. However when i look at the repo there is a warning saying that I have to have the bucket open for public, aren't it possible to get around this? It sounds strange. And also, what do you use for storing these kind of images?
#Choosing image storage
1 messages · Page 1 of 1 (latest)
I was just working on this for a work project myself!
I looked at a few options including AWS, hosting a MinIO image on Fly (we're hosting Remix & Postgres on Fly already), Supabase, DigitalOcean etc. I ended up going with AWS since it was the "safest" option and least likely to need me to babysit it, even though I was pretty jazzed about the MinIO idea.
Usage is pretty simple, patterned off of that S3 example. The one caveat I will mention is something I asked about yesterday, and that's the whole process of uploading from a source URL that contains the binary data you want to upload. I have a workaround (download the image using axios instead of node-fetch) and it doesn't sound like it'd be super relevant to your use case but it might be.
As to public vs private, depends on what you mean. Since you're using the AWS SDK (note that the example is still on v2) you can either use the Bucket Policy or object ACL you want. https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-iam-policies.html
Your use case sounds like a public policy is fine tbh (generate the filename using a uuid() and nobody can guess the location of avatars), but if it's not, then I'd just proxy access to the S3 URL using something like nginx...or maybe a resource route in Remix?
Discord
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
Create multiple users within your AWS account, assign them security credentials, and manage their permissions with IAM policies.
Minio is awesome and works pretty much like AWS. With each release they keep narrowing that gap. What's really nice is the javascript client works with AWS S3 out of the box so you don't have to lock yourself into the AWS api directly. You can target a docker container running minio server and not have to worry about connecting to AWS, makes local development super easy. When its time for prod, just change the client env vars to point to the AWS endpoints and you are good to go (mostly, you still have to understand how to setup S3 security). For my app I leave the S3 bucket private access only and then use a resource route to proxy it. https://docs.min.io/docs/javascript-client-quickstart-guide.html
This quickstart guide will show you how to install the client SDK and execute an example JavaScript program.
Have y'all considered Cloudflare images and R2?