I want copy a folder in aws s3 bucket. I am able to copy files but requirement is I should be able to copy whole s3 folder with some other name.
example: if folder name is project1
I need to copy it as project1-copy
in bucket called my_bucket
. I have tried below code.
$s3->copyObject([
'Bucket' => my_bucket,
'Key' => "project-copy",
'CopySource' => "my_bucket/project1",
]);
and also reverse as
$s3->copyObject([
'Bucket' => my_bucket,
'Key' => "project1",
'CopySource' => "my_bucket/project-copy",
]);
In both case I am getting the error as
Error executing "CopyObject" on "https://s3.us-east-1.amazonaws.com/my_bucket/project1/"; AWS HTTP error: Client error:
PUT https://s3.us-east-1.amazonaws.com/my_bucket/project1/
resulted in a404 Not Found
response: NoSuchKeyThe specified key does not exist.34/F992013F6C3125 (truncated...) NoSuchKey (client): The specified key does not exist. - NoSuchKeyThe specified key does not exist.34/F992013F6C312535YLrCcHhYJzimIKoR2knMvD3smhUbH75piDYTIx5SpKCPNkeWIifaYhKgezxnhpZzOHflzQngTnE=There was an error uploading
And I am sure of I am using right region and folder names also bucket name. Still getting this above error. How can I resolve this.?