The specified key does not exist. When copying an S3 object from one bucket to another
I am trying to copy an S3 object from one bucket to another and the answer looks like this:
`object(stdClass)#24 (3) {
["error"]=> array(2) {
["code"]=> string(9)
"NoSuchKey" ["message"]=> string(33)
"The specified key does not exist."
}
["code"]=> int(404) ["headers"]=> array(1) {
["type"]=> string(15) "application/xml"
}
}
`
This is how the code looks like -
var_dump($this->s3->copyObject('bucket_1','bucket_1/'. images/1.jpg, 'bucket_2', 'bucket_2/images')).die();
As per the signature of the copyObject method , I will need to provide the original object URI and the destination object URI .
Can anyone please help me find out what's going on here?
Thank.
+3
source to share
1 answer
Finally I fixed this after hours of working with amazon docs.
This is what the S3 Object Keys are - http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#object-keys
Since S3 is a flat file system, folders are included in the keys,
$this->s3->copyObject('bucket_1','images/1.jpg, 'bucket_2', 'images/copy_of_2.jpg');
ACL can also be passed as the fifth parameter.
+3
source to share