• 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 29 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 90 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 380 points
0 votes
1 answer 12 views
Problem: Can anyone help me out, I am new to this? In s3, what does rrs stand for? Thanks!!
asked Mar 15 puppetmaster123 300 points
0 votes
1 answer 4 views
Problem I've Googled this question and searched on SO, however, I can't seem to get a straight answer. Can someone please explain What is elastic ip in aws?
asked Mar 8 neeraj 9.5k points
0 votes
1 answer 242 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 626 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 16 views
Problem: the filetype you are attempting to upload is not allowed.
asked Feb 24 Ethan ross 2.3k points
0 votes
1 answer 29 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 16.2k points
0 votes
1 answer 7 views
Problem: I am stuck with this ... Please help me that how to deal with this error? String can’t be coerced into fixnum
asked Mar 22 Ifra 24.4k points