The company I work for stores processed files from their clients on their server and provide each client with a simple page that has a link to the file directory on the server. Each client has a folder and any of these may have many sub folders.
I recently moved this setup to an Amazon S3 bucket. My issue is that when I retrieve the contents of the bucket (using an S3 php class I found online) it returns a massive FLAT array of the entire contents of the bucket. I'm able to filter this so that each client sees their directory only, but converting this some kind of hierarchical data structure for later display is proving to be a massive pain in the ass.
Are there any functions that return S3 items in some manner that reflects their structure? If not this may turn into a question about producing a multidimensional array from a big array of flat arrays.
Thanks! Chris
S3 support listing keys hierarchically using prefix and delimiter, for more informations see the docs.
Use prefix and delimeters to get the list of files.
<?php
$prefix = "jsondata/$folderName/$subFolderName/temp/";
//$bucketname is a root bucket name
$ret = $s3->getObjectsByBucket($bucketname, array(
'prefix' => $prefix,
'delimiter' => ''
));
?>