[英]Copy one directory to another in same amazon s3 bucket
I am working with codeigniter. 我正在与Codeigniter合作。 For Amazon I have used its library.
对于亚马逊,我使用了它的库。
I need to rename a directory in an Amazon S3 bucket. 我需要在Amazon S3存储桶中重命名目录。
For that I used to copy one directory to another directory and the delete old directory after the copy, because I didn't get a direct way to rename the folder. 为此,我曾经将一个目录复制到另一个目录,并在复制后删除了旧目录,因为我没有直接的方法来重命名该文件夹。
I have used this code : 我使用了以下代码:
$ci->s3->copyObject(
$ci->config->item("BUCKET"), //bucket name
$originalPath . $csrf, //source folder
$ci->config->item("BUCKET"), //bucket name
$originalPath . $productId) //destination folder
But this is not working to copy one directory to another. 但这无法将一个目录复制到另一个目录。
Please show me the correct way to rename a folder. 请告诉我重命名文件夹的正确方法。
You can try this to move files from one folder to an existing other with the awscli : 您可以尝试使用awscli 将文件从一个文件夹移动到现有文件夹:
aws s3 mv s3://your_bucket/old_folder/ s3://your_bucket/new_folder/ --recursive
If you want to copy the files change mv
to cp
. 如果要复制文件,请将
mv
更改为cp
。
Please be aware that your old_folder
will not be deleted. 请注意,您的
old_folder
不会被删除。 It just will be empty after all files have been moved. 移动完所有文件后,它将为空。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.