Search code examples
phpamazon-s3zend-framework

Zend Framework Amazon S3. How to create subfolder in a bucket?


How to create subfolder in a bucket?

$s3->createBucket creates only a bucket if I tried $s3->create('bucket/subfolder') it says: bucket name contains invalid characters.

tried this too: $s3->registerStreamWrapper("s3");

and mkdir("s3://bucket/subfolder");

didn't work either.

P.S: credentials are valid. so don't tell me that I'm passing wrong accesKey etc..


Solution

  • S3 doesn't have folders beyond the bucket, but objects (files) can have /s (forward slashes) in their name, and there are methods to retrieve based on a prefix that allows you to emulate a directory-list. This means though, that you can't create an empty folder.