如何使用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 region transfer?
有新闻吗?