Blog Posts with File Uploads using ActiveStorage & Amazon S3 Discussion
How did you get to the Policy section on AWS?
The first ARN success, but the second failed and get an error "Entered ARN is invalid."
"learning-path-blog/*" did i make typo?
hope this helps
https://stackoverflow.com/questions/72719741/invalid-arn-error-while-creating-s3-bucket-policy-using-policy-generator
Wah berarti nggak perlu pakai bahasa inggris nih 😁
Salam kenal, aku juga dari Indonesia
I simply added the object access one line below that (where it's explicitly about objects, not the bucket). Don't know if that's correct, but it works.
Can I ask how? Tried to follow but still stuck as to what to add - for context what I have in the permissions policy editor right now is:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:ListBucket",
"s3:DeleteObject",
"s3:PutObjectAcl"
],
"Resource": "arn:aws:s3:::learning-path-blog-jon"
}
]
}
I would like to confirm what I am thinking. Action Text works with active storage so since I didn't install active storage seperately but did it through action text, I believe my active storage is set for me and doesn't need further configuration should I want to be uploading only images for my application?
Would appreciate some help - when I set the active_storage.service to :local, I am able to reproduce the same results as Chris did. But not with the service pointing at :amazon. I have setup the AWS S3 bucket with the same settings and all the configurations on the codebase. This is the error I get on the browser console:
Access to XMLHttpRequest at 'https://juliano-gorails-blog.s3.amazonaws.com/.....' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
What caused this error for me were 2 things:
My localhost domain was different (localhost instead of 127.0.0.1). I also had to make sure it's not accidentally https locally, because there will be no ssl. I had to make sure to get this right in the CORS policy.
By default storage.yml names the bucket with the rails environment at the end (using some ERB). I kept it there, named my bucket "blabla-production" and of course got an error in "development" :P. Make sure your bucket name in storage.yml actually matches the name on S3.
Hello Chris and rails developers, for sure that was the most challenging part of this series of tutorials, In my case everything work as was explained but in production when I use render The image is uploaded but I can not see it. Maybe any idea about this problem.
Hey there I am Diego from the future, my problem was I use a image with SVG format, I don't go deep in the problem but apparently there are some image formats that don't work well I change to jpg and work as expected.
I'm getting KeyError in BlogPosts#index
'Missing configuration for the amazon Active Storage service. Configurations available for the test and local services.'
If you are receiving this error: "Token is invalid and failed to refresh."
Do this on your terminal:
aws configure --profile YOUR-PROFILE-NAME
AWS Access Key ID [None]: YOUR-ACCESS-KEY-ID
AWS Secret Access Key [None]: YOUR-SECRET-ACCESS-KEY
Default region name [None]: YOUR-REGION
Default output format [None]: json
to list:
aws configure list
In my case I also needed to update config.active_storage.service = :amazon
at config/environments/development.rb and config/environments/production.rb
Hi , found problem with Action Text. For example, we have a blog model with a content field (action text field). We have attached the image (at this point it has been uploaded to amazon s3) and are not saving the blog. Result: We have a file on amazon s3 that is not tied to anything
This issue is currently plaguing this tutorial on updated rails and ruby. https://github.com/rails/rails/issues/52127
In case this might help anyone, I had to add both the 'http' and https' version of the Render URL to the CORS configuration for it to function properly.