Build a Blog with Rails Part 17: Handling File Uploads with ActiveStorage & Amazon S3
Vložit
- čas přidán 2. 04. 2023
- ► Check out gorails.com for Pro episodes and more!
► SaaS business template for Ruby on Rails with built-in features like Payments, Teams, and much more: jumpstartrails.com
► Ruby on Rails hosting with Hatchbox.io: hatchbox.io
► Learn how to add Stripe Payments (with SCA support!) with Ruby on Rails: courses.gorails.com/payments-... - Věda a technologie
Set this up with no issues, awesome tutorial. I actually smiled when you talked about how difficult it was because you made it seem so easy. Deeply appreciate all the help you put out in this series for free!
That makes my day!
Awesome! You have no idea how much your video content has come to my rescue! Your explanation of active storage with Amazon S3 was top-notch and incredibly helpful. Thank you so much!
Glad you found it helpful!!
It was hard but I've gone through this! Thank you! 💯👍 GoRails🚀
Great job!!
Great series! Thanks so much!
Just used this in the wild, thanks Chris
Excellent! Hope it went smoothly!
This was what i was looking for, thank you!
I’m using rails as a backend and returning a link to my images to render in my react app. What’s the correct way to get the s3 url?
I originally used rails_blob_path when everything was local, but I believe object.image.url is the way to get the s3 link. But I saw someone say that the predecessor to this, object.image.service_url was frowned upon. Is that still the case?
Hello and thanks for the video! Question: Where all the other files of your database are stored. Like the text of the posts not only the images or users data?
Depends on your database but they will always store it on disk in the databases data directory.
So, do you need another s3 bucket for example users credentials or they stored in a postgres database?
Your videos are always so informative and helpful! Seriously you do so much for the community. Question - have you tried to do this same approach, but using a policy on an IAM role that is assigned to the EC2 instance? This method won't create an access/secret key like you need in the storage.yml. This is useful given an environment where you can't create users. All my testing has been unsuccessful thus far :(
I think you always need keys to login.
@@GorailsTV I was able to figure it out, well somewhat! In production it will work, but for local dev it won't work. For local dev it is just as you said where you need keys. In production though, you can omit the keys and as long as the IAM role is configured properly everything should work.
Hi! I am really enjoying your series so far. When I upload an image while editing a blog post, the image shows. When I update the blog post, the image doesn't show. Looking into the console, I am getting the following error" "ActiveStorage::Representations::RedirectController#show wrong number of arguments(given 1, expected 0) ". I made sure I had vips installed and tried installing different versions of image_processing (where the error comes from) and nothing has worked so far. Any help would be appreciated and thanks!
That's a good question. Share the full stacktrace if you get a chance.
Hey go rails! I have a question If I use action text for some blog post. Since these blog posts are not many can instead of uploading files in Amazon s3, I can store them in my app? Thanks!!
You can use the file store but your hosting service would need persistent disk storage in production. So a place like Heroku wouldn't work because they run everything in containers but a hosting service like Hatchbox.io that we run does support persistent disk storage.
If my app is to have users, and users uploading images under their account AND only owner of images can access/view the images - Will the ACL be disalbed?
Leave them as private.
My god it’s Litteraly a hell storm just to connect the app to the damn bucket so frustrating
Good old Amazon for you!
Hey I actually went through it slowly and finally got my rails app connected to the bucket . THANK YOU !
But I need your help really badly I am having serious trouble now
I tried sending the urls back to the frontend . And it’s not recognizing them and it’s crashing on frontend.
I used rails_blob_path , rails_blob_url and more with disposition: “attached”
Only sending the service url works but then it won’t download when plugged into the href (I have download attribute in href tag )
HELP PLEASE !!!