PUT Object 仅复制文件,因此在成功复制操作后仍需要通过 DELETE Object 显式删除文件,但这只是另外几个一旦处理存储桶和文件名的整体脚本就位(也有相应的示例,请参见例如 每个请求删除一个对象).I'd like to copy some files from a production bucket to a development bucket daily.For example:Copy productionbucket/feed/feedname/dateto developmentbucket/feed/feedname/dateBecause the files I want are so deep in the folder structure, it's too time consuming to go to each folder and copy/paste.I've played around with mounting drives to each bucket and writing a windows batch script, but that is very slow and it unnecessarily downloads all the files/folders to the local server and back up again. 解决方案 UpdateAs pointed out by alberge (+1), nowadays the excellent AWS Command Line Interface provides the most versatile approach for interacting with (almost) all things AWS - it meanwhile covers most services' APIs and also features higher level S3 commands for dealing with your use case specifically, see the AWS CLI reference for S3:sync - Syncs directories and S3 prefixes. Your use case is covered by Example 2 (more fine grained usage with --exclude, --include and prefix handling etc. is also available):For completeness, I'll mention that the lower level S3 commands are also still available via the s3api sub command, which would allow to directly translate any SDK based solution to the AWS CLI before adopting its higher level functionality eventually.Initial AnswerMoving files between S3 buckets can be achieved by means of the PUT Object - Copy API (followed by DELETE Object):There are respective samples for all existing AWS SDKs available, see Copying Objects in a Single Operation. Naturally, a scripting based solution would be the obvious first choice here, so Copy an Object Using the AWS SDK for Ruby might be a good starting point; if you prefer Python instead, the same can be achieved via boto as well of course, see method copy_key() within boto's S3 API documentation.PUT Object only copies files, so you'll need to explicitly delete a file via DELETE Object still after a successful copy operation, but that will be just another few lines once the overall script handling the bucket and file names is in place (there are respective examples as well, see e.g. Deleting One Object Per Request). 这篇关于在 S3 存储桶之间移动文件的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!