問題:
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