Ruby on Rails #21 Active Storage With Amazon S3 Cloud Storage
Vložit
- čas přidán 8. 05. 2024
- aws s3 for file storage:
github.com/corsego/20-active_...
ActiveStorage docs:
edgeguides.rubyonrails.org/ac...
How to use Credentials in Ruby on Rails 6? TLDR:
blog.corsego.com/ruby-on-rail...
0:00 The Problem
02:01 Install AWS S3 cloud storage
05:19 AWS IAM
08:35 Local storage = S3
09:13 gem aws-sdk-s3
11:05 Production
15:42 Summary
Clear and concise. Thank you so much!
You're videos are so great for a newbie coder like me! I'm building my first app and was able to follow along easily! Many thanks!
Great video! Very easy to understand and follow!
I just have to say that every time I get stuck with something, I come to your channel to see if you have a video. It never fails that you've already covered the question that I have! I'm grateful that you walked us through the S3 bucket creation . Everyone else glosses over those details like I should already know which settings should be selected.
Your channel is actually amazing. I've been hitting my head for days on it. Following your video, i made it work in less than an hour. Huge thanks
Great video serie!!
thanks for the video!
Very nice and helpful video, Thank a lot :)
Great video my friend, i'm a rails lover
loved it!!!! thankuu, subbed!
Thanks!
thx
Perfect!
Hello Evgenii! Glad that you found the video useful!
Epic.
perfect¡¡
Thanks! If you have any ideas for upcoming episodes - please share them!
do you have video that explain to delete orphaned image file after upload
Hello. I followed your video, however Heroku doesnt take amazon as storage service. It take local configuration. My production.rb has config.active_storage.service = :amazon and i have my credentials set up ok. do you have an idea what is the problem?
What if we want to save our images in a specific folder/directory inside the bucket ? how we would go about that in rails ? thanks in advance.
Good question. I haven't researched it before. The easy way - different buckets for different info. It wouldn't really increase your aws cost. You can override where a file is saved like "has_one_attached :avatar, service: :s3"
I'm having a problem, when i do rails credentials:edit it opens an empty yml file but when I do credentials:show it shows me the default aws stuff so it isn't opening correct file. Can someone help me?
Hero without cape
Good tutorial ! But i keep getting an error in uploading in the xml response. "The request signature we calculated does not match the signature you provided. Check your key and signing method." "SignatureDoesNotMatch" seems like a key/secret error but i have changed it to newer ones and the issue persists atm
Did you update CORS?
@@SupeRails yes i've added on my bucket -> Security a json for it.
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": [],
"MaxAgeSeconds": 3000
}
]
also i didn't deploy to heroku, i wanted to try in ENV=Development first. I followed along all your steps and somehow got a different outcome so far
stackoverflow.com/a/62137151/5695646
@@SupeRails so i found out my issue and it was whit the CORS. Notice on the reply here i wasn't allowing any "POST","PUT" or "Delete" methods and they are needed. Ill leave my CORS file in here hope it helps.
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD",
"POST",
"PUT",
"DELETE"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": []
}
]
first of all thank you for your great video
but what if i want to upload photos in subdirectories at AWS, for example:
photos/user_id/profile_photo.jpeg
how to do this using active storage?
That's a tough one. Instead of sub-directories, I would maybe just use different AWS buckets... Anyway, did you find an answer? Now I'm curious!
@@SupeRails You can't do it. I remember this being an issue when Active Storage first came out. Then someone from Rails Core, or Basecamp, said they will not do anything to make it work with folders. Also, thanks for the video.