user2119554
user2119554

Reputation: 320

The specified key does not exist - While copying S3 object from one bucket to another

I am trying to copy a S3 object from one bucket to another and the response is 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"
    } 
 }

Here is how the code looks -

var_dump($this->s3->copyObject('bucket_1','bucket_1/'. images/1.jpg, 'bucket_2', 'bucket_2/images')).die();

According to method signature of copyObject I would need to supply Source object URI and Destination object URI.

What's going wrong here?

Upvotes: 5

Views: 22979

Answers (1)

user2119554
user2119554

Reputation: 320

Finally I fixed it after few hours of looking into amazon docs.

Here is what S3 Object keys are -http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#object-keys

As S3 is a flat file system, the folders are includes in keys,

$this->s3->copyObject('bucket_1','images/1.jpg, 'bucket_2', 'images/copy_of_2.jpg');

ACL can also be passed as a fifth parameters.

Upvotes: 5

Related Questions