• Register
0 votes
369 views

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],   
    )
end

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?

7.5k 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:

https://s3.amazonaws.com/bucketname/filePath/filename

Then I replaced it as follows :

https://bucketname.s3.amazonaws.com/filePath/filename

 OR

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.

38.6k points

Related questions

0 votes
1 answer 5 views
5 views
Problem: AWS S3: The bucket you are attempting to access must be addressed using the specified endpoint.
asked Jul 3 Priscilla Gurpreet 74.7k points
0 votes
1 answer 63 views
63 views
https://intellipaat.com/community/46032/restricting-the-access-to-the-contents-delivered-in-aws-cloudfront
asked May 24 Yash verma 4k points
0 votes
1 answer 98 views
98 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 46 views
46 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 9 views
9 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 10.5k points
0 votes
1 answer 139 views
139 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 1 view
1 view
Problem: Homebrew must be run under ruby 2.3!
asked 5 days ago Aurelia Maja 78.4k points
0 votes
1 answer 18 views
18 views
Problem: Is there someone who can help : Error: must be owner of extension plpgsql?
asked Jun 2 Rada Gracelynn 104k points
0 votes
1 answer 14 views
14 views
Problem: Asked few friends but no solution, please help >Homebrew must be run under ruby 2.3! you're running 2.0.0
asked May 10 Sawyer Parviz 168k points
0 votes
1 answer 16 views
16 views
Problem: What is it? >Homebrew must be run under ruby 2.3! you're running 2.0.0.
asked May 9 Florina Gulnar 106k points