waffles
waffles

Reputation: 33

S3 copy object inside a bucket subfolder (PHP)

Can someone please end my misery? I've been trying to figure out how to copy an object inside a bucket/folder for a couple days now. Here's my code that works for when copying inside a bucket -

$s3->batch()->copy_object(array( // Source.
    'bucket' => $this->bucketName,
    'filename' => $source
),
array( // Target.
    'bucket'   => $this->bucketName,
    'filename' => $target
)
);

$responses = $s3->batch()->send();

I have a folder named "thumbs" inside my main bucket that I want to copy some files around in. I've read about prefixes and delimeters and all of that but I can't find any docs about where to specify that inside the copy object method? I know it's going to be something so easy but I just can't figure it out.

Can someone please help? Thanks a bunch!

Upvotes: 1

Views: 2384

Answers (1)

user149341
user149341

Reputation:

Prefixes and delimiters are only used when listing a bucket. To copy a file that's within a "folder", just specify the path of the file as the filename. For instance, in this case, you might set $source to thumbs/image.jpeg.

Upvotes: 1

Related Questions