AWS S3复制两个水桶之间的文件和文件夹水桶、文件夹、两个、文件

2023-09-11 08:25:46 作者:心中千万只草尼玛在咆哮

我一直在寻找一种工具来帮助我复制一个S3存储的内容到第二桶没有先下载内容到本地系统。

I've been looking for a tool to help me copy content of an S3 bucket into a second bucket without downloading the content first to a local system.

我已经试过AWS S3控制台复制选项,但会导致一些嵌套的文件被丢失。

I've tried AWS S3 console copy option but that resulted in some nested files being missing.

我曾尝试使用传输的应用程序(恐慌),但重复的命令将文件复制第一个到本地系统然后返回第二桶

I have tried to use Transmit app (Panic) but the duplicate command copies files first to the local system then to back to second bucket

推荐答案

使用AWS-SDK创业板简单的例子:

A simplified example using the aws-sdk gem:

AWS.config(:access_key_id => '...', :secret_access_key => '...')
s3 = AWS::S3.new
s3.buckets['bucket-name'].objects['source-key'].copy_to('target-key')

如果您要执行不同的桶之间的拷贝,然后指定目标斗名称:

If you want to perform the copy between different buckets, then specify the target bucket name:

s3.buckets['bucket-name'].objects['source-key'].copy_to('target-key', :bucket_name => 'target-bucket')