草庐IT

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

coder 2025-04-04 原文

我正在尝试使用 AWS-SDK-Core Ruby Gem 删除上传的图像文件。

我有以下代码:

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

但是,我收到以下错误:

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

我知道该区域是正确的,因为如果我将其更改为 us-east-1,则会出现以下错误:

The specified key does not exist.

我在这里做错了什么?

最佳答案

这个存储桶似乎是在不同的区域创建的,IE 不是 us-west-2。那是我唯一一次看到“您尝试访问的存储桶必须使用指定端点寻址。请将所有 future 请求发送到此端点。”

US Standard is us-east-1

关于ruby-on-rails - AWS S3 : The bucket you are attempting to access must be addressed using the specified endpoint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25027462/

有关ruby-on-rails - AWS S3 : The bucket you are attempting to access must be addressed using the specified endpoint的更多相关文章

随机推荐