Amazon S3 file request error - ruby-on-rails

I am currently attempting to implement Amazon S3 into my rails application but am walking into an issue.
The gems i am using is CarrierWave and Fog.
This is the error i get when i try visit a file/image url.
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>42B0F41E7EF92ACC</RequestId>
<HostId>ESYXvkVKxnsu32LjfcsiErZ27IK44ItREPB68sBBHXqWHtzkN9fnc04oj8IzCEFg</HostId>
</Error>
This is the url my app is serving to view the image
https://vapenz-images.s3.amazonaws.com/uploads/product_image/image/2/Capture.PNG?AWSAccessKeyId=AKIAIEWRNU2VPG5SF7XQ&Signature=GcjA%2Bx46Q9wU%2BuaffhfCTLbLuAY%3D&Expires=1414545697
And here is a picture of the permissions.
My rails app currently can upload a image to s3 but it cant view them, i am quite lost.
Thanks for the help!

Related

Active Storage Links (AWS-S3) went missing after redeploying the app to heroku

Has anyone encountered this issue where your file links (using Active Storage and AWS-S3) suddenly just go missing after - redeploying/updating your app on Heroku?
I'm currently working on an app using Rails 6, Ruby 2.6 and Postgres. This is the very first time I've experience the missing link issue.
Just to give a clearer picture. The file link is clickable. Hence, it means that i.e. user.avatar.attached? returns true.
Upon clicking on the file link, i was returned with the 404 error and message saying page not found.
Was your file successfully uploaded to AWS S3?
Perhaps share your file url ? I am using AWS S3 too and my files has this url: .s3.amazonaws.com ,
Heroku will delete files after a few hours if it is not hosted on AWS

403 Forbidden Error for accessing images on google cloud bucket after transferred from one bucket to another

Actually I am using google cloud bucket for image upload in my rails app. I am using paper clip for image upload. I have used bucket name "abcd-old". I uploaded some of the images through app. It was working fine. But as of now I transffered the content of "abcd-old" bucket to new bucket "abcd-new". Also set the same permission as it was for old one. But now images are broken in the app. it shows "403 forbidden error". If I upload new image that will work. But old I mean transffered images are broken. Please help me on this.
This is the error I am getting
<Error>
<Code>AccessDenied</Code>
<Message>Access denied.</Message>
<Details>
Anonymous users does not have storage.objects.list access to bucket abcd-new.
</Details>
</Error>
We can resolve this issue by command line
gsutil -m acl -r set public-read gs://abcd-new
Please go through this link for more details http://tekhoow.blogspot.in/2015/12/soving-accessdenied-on-google-cloud.html

I've uploaded an image for my website on s3 but it doesn't display on my website

I've uploaded an image for my website on s3 but it doesn't display on my website. It works fine on my localhost, as the picture is in my assests/images folder of my Rails 5 app, but not on Heroku. When I inspect my page, I do see an error for the file my code is looking for: Failed to load resource: the server responded with a status of 404 (Not Found) .I do believe I have my Heroku set up right with my amazon s3 bucket because I can see users' pictures being sent to it. I'm looking to use this picture as a background for part of my landing page. Any help would be great, thanks.
I made the image inside my 's3 bucket' public so that it could be accessed by my website. Also, I changed my url for the image in my Rails app to the new url provided by amazon s3.

Amazon S3: How to display custom message instead of access denied 403

I am trying to access the uploaded files on the Amazon s3 bucket using the Rails application. When I click on the specific link, getting following error.
This XML file does not appear to have any style information associated with it. The document tree is shown below. <Error>
<Code>AccessDenied</Code>
<Message>Request has expired</Message>
<X-Amz-Expires>600</X-Amz-Expires>
<Expires>2016-07-20T22:22:58Z</Expires>
<ServerTime>2016-07-20T22:33:21Z</ServerTime>
<RequestId>461898B9DD2599A6</RequestId>
<HostId>
jAarpDNUJn+SygprDBXP/EnI9vN5sAR2OUqXSQ7UwsIXSAB6HR9OoYpmd3RXmxXv9AlZG+wsL8s=
</HostId>
</Error>
How to display custom error message instead of "Access Denied" page?

Cloudfront + S3 permissions

Some background. I'm using Rails + Carrierwave + S3 + Cloudfront.
I have a bucket and in the bucket there are many files. All the files are public. There is one file in particular. I can go to it on the S3 Console, select it, click on properties, and click on the link. It's a photo, so the photo will appear. I'm assuming that because I can do this, the photo has the correct public permissions.
I have a Cloudfront distribution pointing to this bucket. The Restrict Bucket Access is set to NO.
When I try to look at the photo through Cloudfront I get the error:
<Error>
<script/>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>blah</RequestId>
<HostId>
blahblahblah
</HostId>
</Error>
This is driving me absolutely bonkers. If anyone has any suggestions, I'd greatly appreciate it!

Resources