如何使用 ruby aws-sdk-s3 gem 在 AWS S3 中不同区域的存储桶之间复制文件?存储桶位于区域中:“ eu-central-1 ”(target_bucket)和“ eu-west-1 ”(source_bucket)。我想将s3://source_bucket/name_base.checksum复制到s3://target_bucket/source_bucket/name_base.checksum
错误:
[ERROR] The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
测试红宝石代码:
require 'aws-sdk-s3'
source_bucket = 'source_bucket'
target_bucket = 'target_bucket'
name_base = 'funny_name'
begin
s3 = Aws::S3::Client.new(
access_key_id: '***',
secret_access_key: '***',
region: 'eu-west-1' # I tested also 'eu-central-1'
)
s3.copy_object({
bucket: "#{target_bucket}",
copy_source: "#{source_bucket}/#{name_base}.checksum",
key: "#{source_bucket}/#{name_base}.checksum"
})
rescue Aws::S3::Errors::ServiceError => e
puts "[ERROR] #{e.message}"
end
我在文档中找不到有关此用例的任何有用信息: https ://docs.aws.amazon.com/AmazonS3/latest/dev/CopyingObjectUsingRuby.html https://docs.aws.amazon.com/sdkforruby/ api/Aws/S3/Client.html#copy_object-instance_method
我发现了 2011 年的旧线程我希望在这种情况下有所改变: Amazon S3 区域转移?
任何新闻?