AWS S3 SDK for PHP, loading into folders inside the bucket

I am just starting with the AWS S3 SDK for PHP, I managed to load the folder of elements from my PC into the s3 bucket using PHP, is there any way to specify the folder inside this bucket, for example, instead of loading image.jpg into imagebucket, it loads to the image folder inside the "imagebucket".

+6
source share
2 answers

Aws s3 lacks the concept of folders. Its just for the display used by Amazon AWS UI.

In fact, it saves the file name as a key and data as a value.

if you store 5 files with different folders, they are not going to create 5 folders.

+5
source

From the docs:

public function uploadDirectory($directory, $bucket, $keyPrefix = null, array $options = array()) 

By specifying $ keyPrefix, you can force downloaded objects to fit under the virtual folder into the Amazon S3 bucket. For example, if $ bucket name is my-bucket and $ keyPrefix is ​​'testing /', then your files will be uploaded to my container in the test / 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

+4
source

Source: https://habr.com/ru/post/917104/


All Articles