amazon-s3-php-class icon indicating copy to clipboard operation
amazon-s3-php-class copied to clipboard

Bucket folder support?

Open misbach opened this issue 11 years ago • 6 comments

I can't see that this library supports bucket folders, is that true? Could I persuade someone to issue a pull request adding this functionality?

Great work on this library. I know AWS has their on sdk, but this is small and simple. thanks.

misbach avatar Nov 25 '13 07:11 misbach

To upload into a bucket folder just add the folder name where you provide the bucket info.

For example :

S3::putObject( S3::inputFile("foo.jpg", false), "yourBucket/folderName", "foo.jpg",

StratusBase avatar Dec 07 '13 13:12 StratusBase

Is there a similar way to get from a bucket folder? It doesn't seem scalable to have to download the contents of the entire bucket and then filter through that list just to get the files that I want. Looking through the code it looks like the S3Request class has a $uri parameter that might have been intended to help with this??

joeelizondo avatar Mar 07 '14 21:03 joeelizondo

@StratusBase If you get an error message about needing to use the specified endpoint..

If your bucket is not in the US Standard region, you cannot use the path-style syntax for folders. There's a brief conversation in http://www.sitefinity.com/developer-network/forums/set-up-installation/amazon-s3---must-be-addressed-using-the-specified-endpoint about this.

If you need your bucket to NOT be in the US Standard region, there may be another approach but I haven't looked into that.

ghost avatar Mar 26 '14 22:03 ghost

Placing the the directory path as part of the file name worked me. So Based on Stratusbase's example above. The third param should contain the folder and the file name.

S3::putObject( S3::inputFile("foo.jpg", false), "yourBucket", "folderName/foo.jpg",

t14 avatar Sep 09 '15 09:09 t14

Any fix for this yet? Would like to fetch a folder from us-east-2. The solution is to change to "bucket.s3.us-east-2.amazonaws.com" then the path method should work. I'm just not sure at this time how to do it. I managed to almost have it working but could not eliminate a single "." at the end of the URL.

Any help is greatly appreciated.

alexstine avatar Oct 02 '17 15:10 alexstine

Careful when you specify the folder + filename. There must not be a leading slash. @t14 has the correct solution.

martindrapeau avatar Oct 13 '17 18:10 martindrapeau