I want to copy a folder (size 150MB - 200MB) of one S3 bucket to another S3 bucket of the different region using PHP or in S3 term "duplicate all objects with the prefix of an S3 bucket into objects with a different prefix to another S3 bucket"
I have tried below code but it's not workings
$s3 = new S3Client(['credentials' => $credentials, 'version' => 'latest','region' => $region,'debug' => false ]);
$s3->registerStreamWrapper();
$result = $s3->uploadDirectory("s3://{$source_bucket}/{$key}",$target_bucket);
and I have also tried to list out all objects (using listObject function) from source bucket then copy it (Using copyObject function ) into destination bucket. But this process is consuming too much time.
Any suggestion
If you are not trying to do an automated copy, you should use the S3 console.
Someone had your problem before: How can I copy clone/duplicate a folder on S3?
You really, really should use something like the aws s3 sync
command in the AWS Command-Line Interface (CLI).
If you write it yourself, you will need to recurse through all the files and issue an individual copy
command for each object, plus error handling. There is no "copy all files in this path" command in Amazon S3.