AWS S3: The bucket you are attempting to access must be addressed using the specified endpoint

问题:

I am trying to delete uploaded image files with the AWS-SDK-Core Ruby Gem.我正在尝试使用 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:我知道该区域是正确的,因为如果我将其更改为us-east-1 ,则会出现以下错误:

The specified key does not exist.指定的键不存在。

What am I doing wrong here?我在这里做错了什么?


解决方案:

参考一: https://en.stackoom.com/question/1h0mk
参考二: https://stackoom.com/question/1h0mk
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章