我有一堆存储在 Amazon S3 中的 blob。Ruby aws-sdk gem 似乎支持 Swift,我们只需要传递端点:
swift_client = Aws::S3::Resource.new(
endpoint: 'https://swift.me.com/,
bucket: 'bucket',
credentials: Aws::Credentials.new(access_key_id, secret_access_key))
swift_bucket = swift_client.bucket('bucket')
s3_client = Aws::S3::Resource.new(
region: 'us-east-1',
bucket: 'bucket',
credentials: Aws::Credentials.new(access_key_id, secret_access_key))
s3_bucket = s3_client.bucket('s3-bucket')
# This object exists, s3_object.exists? => true
s3_object = s3_bucket.object('SOMEUID')
swift_object = swift_bucket.object('SOMEUID') # UID is the same as in S3
# I want to copy s3 object to swift, so I do:
swift_object.copy_from(copy_source: "#{s3_bucket.name}/#{s3_object.key}")
此时我得到“Aws::S3::Errors::NoSuchKey:指定的密钥不存在。”。如果我反过来做同样的事情(从 Swift 到 S3),它工作正常。
甚至可以使用 aws-sdk gem 将数据从 S3 复制到 Swift 还是我应该寻找其他工具?