Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in AWS by (19.1k points)

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

I have the following 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

However, I am getting the following error:

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

I know the region is correct because if I change it to us-east-1, the following error shows up:

The specified key does not exist.

What am I doing wrong here?

closed

1 Answer

0 votes
by (44.4k points)
selected by
 
Best answer

If you receive this statement:

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

Then your bucket must have been created in a different region. The standard US region is us-east-1 

Do you want to master AWS, then do checkout the aws certification training by Intellipaat.

Related questions

0 votes
1 answer
Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...