I'm just getting started with the AWS S3 SDK for PHP, I've managed to upload a folder of items from my PC to an s3 bucket using PHP, is there any way to specify a folder inside that bucket, for example, instead of uploading image.jpg to imagebucket, it uploads to the folder called images inside 'imagebucket'.
6
votes
2 Answers
5
votes
4
votes
From the docs:
public function uploadDirectory($directory, $bucket, $keyPrefix = null, array $options = array())
By specifying $keyPrefix, you can cause the uploaded objects to be placed under a virtual folder in the Amazon S3 bucket. For example, if the $bucket name is my-bucket and the $keyPrefix is 'testing/', then your files will be uploaded to my-bucket under the testing/ virtual folder: https://my-bucket.s3.amazonaws.com/testing/filename.txt
$s3->create_object($bucket, 'folder/filename', $options)
work? – lanzz