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'.
There is no concept of folders in aws s3. Its just for display purpose used by amazon AWS UI.
Actually it stores filename as key & data as value.
if you store 5 files with different folders, they are not going to create 5 folders.
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
See: http://docs.aws.amazon.com/aws-sdk-php/guide/latest/service-s3.html#uploading-a-directory-to-a-bucket
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With