I am working with codeigniter. For Amazon I have used its library.
I need to rename a directory in an Amazon S3 bucket.
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 :
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
.
Please be aware that your old_folder
will not be deleted. It just will be empty after all files have been moved.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.