views:

372

answers:

1

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 either: $s3->registerStreamWrapper("s3");

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..

+2  A: 

S3 doesn't have folders beyond the bucket, but objects (files) can have /s 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.

Greg
But I can do it with S3Fox, why?
are you sure you haven't created a file with a name ending in / ? ('newfolder/') (it wouldn't mean you couldn't also have a file called 'newfolder/1.jpg'). What's the actual use case for wanting an empty folder, anyway?
Greg
ok I think I got it! thanks Greg!