Amazon S3将目录复制到另一个目录 [英] Amazon S3 copy the directory to another directory

查看:249
本文介绍了Amazon S3将目录复制到另一个目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用PHP API将包含子文件夹和文件的文件夹复制/复制到S3存储库中的另一个目录中?

How do i copy/duplicate a folder that contain sub-folders and files into another directory within the S3 bucket using PHP API?

$ s3-> copy_object 仅复制文件夹,但不能复制文件和子文件夹。

$s3->copy_object only copies the folder, but not the files and sub-folders inside.

我必须使用 $ s3-> list_objects 获取所有文件和目录,并在每个文件/目录上运行 $ s3-> copy_object

Do i have to use $s3->list_objects to get all files and directory and run $s3->copy_object on every single file/directory?

推荐答案

S3不是一个文件系统,它是一个对象存储。文件夹实际上并不存在任何有形的含义;一个文件夹只是你可以调用一个共享的前缀。换句话说,如果您创建 path / to / one path / to / two ,那么它也不会导致路径 path / to 存在。如果您看到它们,那是因为某些组件获取了一个对象列表,将它们的键分割为 / ,并决定将该列表显示为层次结构。

S3 is not a filesystem, it's an object store. Folders don't actually exist in any tangible sense; a folder is just something you can call a shared prefix. Put another way, if you create path/to/one and path/to/two, it doesn't also cause path and path/to to exist. If you see them, that's because some component took a list of objects, split their keys on /, and decided to display that list as a hierarchy.

您要将文件夹复制到另一个文件夹。将其改为S3条款,您要将具有相同前缀的所有对象复制到具有不同前缀的对象。这样做使得方法清除:使用一个前缀获取对象列表,然后复制每个对象。

You want to "duplicate a folder into another folder". Rephrasing this into S3 terms, you want to "duplicate all objects with the same prefix into objects with a different prefix". Saying it that way makes the method clear: get a list of objects with the one prefix, then copy each of them.

这篇关于Amazon S3将目录复制到另一个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆