• Register
0 votes

Problem :

I want to delete the uploaded image files with the AWS-SDK-Core Ruby Gem.

I have the below code:

require 'aws-sdk-core'
def pull_picture(picture)
    Aws.config = {
        :access_key_id => ENV["AWS_ACCESS_KEY_ID"],
        :secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"],
        :region => 'us-west-2'
    s3 = Aws::S3::Client.new
    test = s3.get_object(
        :bucket => ENV["AWS_S3_BUCKET"],
        :key => picture.image_url.split('/')[-2],   

But I am getting the below error:

The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

I am sure that the region is correct as if I try to change it to us-east-1, the below error comes up:

The specified key does not exist.

May I know how can I resolve this issue?

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I had faced the similar kind of error in the recent past as my bucket was in region us-west-2 and my URL pattern had the bucketname in the path. When I changed my URL pattern to have bucketname as URL subdomain to grab the files and it just worked for me.

e.g. My previous URL was as follows:


Then I replaced it as follows :



I also have faced the same issue in the past. After a lot of research I found that the root cause of issue was with my com.amazonaws dependencies. After I added the dependencies my error got disappeared.

9 7 4
38,600 points

Related questions

0 votes
1 answer 16 views
Problem: I am trying to create a Security Group using the AWS SDK but it is failing to authenticate it. For a very specific Access Key and Secret Key I have already provided the Administrative rights and then also it fails to validate. I also tried ... .java:1146) at com.sunil.demo.ec2.SetupEC2.createSecurityGroup(SetupEC2.java:84) at com.sunil.demo.ec2.SetupEC2.main(SetupEC2.java:25)
asked Aug 24, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 33 views
Problem: Hello Kodlogs, I tried pushing my app and I got an error message of this nature; you must use bundler 2 or greater with this lockfile. What can I do to correct this?
asked Nov 2, 2020 Festus James 360 points
0 votes
1 answer 19 views
Problem: When i open my phpmyadmin it gives me this error failed to set session cookie. maybe you are using http instead of https to access phpmyadmin.
asked Nov 12, 2020 prog_learner 2.5k points
0 votes
1 answer 189 views
Problem : I am trying to install the gem using gem install mygem or update a RubyGems using gem update --system, and it fails with below error: ERROR:  While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory. Does anyone have the idea how to fix this error?
asked Jan 22, 2020 jwilliam 3.9k points
0 votes
2 answers 484 views
Problem : I am facing following AWS error the authorization mechanism you have provided is not supported. please use aws4-hmac-sha256.
asked Nov 16, 2019 peterlaw 6.9k points
0 votes
1 answer 6 views
Problem: t looks like I have a circular issue regarding Ruby over Rails migration procedure. I am following the online available article and now reached the point where I need to modify my very first table. I ran the following, [tims@web2 working_ror]# rails generate model ... was to drop and rebuild everything below. rake db: drop rake db: create rake db: distant and the conclusions are all same.
asked Dec 1, 2020 sasha 5.3k points
0 votes
1 answer 1.6K views
Problem : When I try to open the terminal and enter the following command: sudo mongod The output is received as below: [initandlisten] waiting for connections on port 27017 When I try to open another terminal and enter following command: sudo mongo I will open the mongo ... never posts the data. So I think my problem lies within mongo but I am unable to figure it out. POST /info 200 120002ms
asked Dec 12, 2019 alecxe 7.5k points
0 votes
1 answer 76 views
Problem : I am struggling to find out what is actually happening with my code. My scripts were working fine for some time and suddenly they have half stopped. I am trying to access my api and I am getting back the access token. With my access token, I can access ... to use sessions on the site to keep track of the internal user ids. Unable to know if my sessions could be causing the problem.
asked Jan 10, 2020 alecxe 7.5k points
1 vote
1 answer 82 views
Problem : Currently I am struggling to find out what is actually happening with my code. My all scripts were working really fine previously but now they are suddenly half stopped. I am trying to access the api but I am getting back the access token. ... am facing below error : Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user.
asked Dec 30, 2019 alecxe 7.5k points