isimpledesign Posted January 21, 2011 Share Posted January 21, 2011 Hi What i am trying to do is just show the content off a folder within one off my buckets instead off everything in the bucket? So i have included the Amazon S3 class and added my credentials. here is where i grab the bucket. // Get the contents of our bucket $contents = $s3->getBucket($amazon_bucket); print_r($contents); Ok so from the print_r i get a long array off everything in my chosen bucket here is one iteration off the array. Array ( [name] => dnb/Rusko - Hold On (feat. Amber Coffman) (Sub Focus Remix)(1).mp3 [time] => 1295307197 [size] => 6492663 [hash] => e5a75949ddadd924249ef8acfdded2de ) [dnb/Sleep Walk_Dub Zero_192.mp3] => So now if i run a foreach through the bucket i can grab sections out off the array. foreach ($contents as $file){?> $fname = $file['name']; $furl = "http://$amazon_bucket.s3.amazonaws.com/".$fname; <li><a class="video_click" href="<?php echo $furl; ?>" rel="prettyPhoto" title="Flash 10 demo"><?php echo "$fname"; ?></a></li> } so instead off showing me everything in the bucket which it does, i only want it to show me everything in the dnb folder. The only way i can think to do it is strip the content before the / dnb/Rusko - Hold On (feat. Amber Coffman) (Sub Focus Remix)(1).mp3 strip the dnb then add again. " add folder here "/Rusko - Hold On (feat. Amber Coffman) (Sub Focus Remix)(1).mp3 and then append it again has anyone got a solution for this cant find any real solutions on google any help. Thanks Quote Link to comment Share on other sites More sharing options...
salathe Posted January 21, 2011 Share Posted January 21, 2011 So i have included the Amazon S3 class ... Which one? There are many! For what it's worth, if you use Amazon's own PHP library then you can call the AmazonS3 class's get_object_list() method with a prefix string, or regular expression, to get only the objects that you want. See http://docs.amazonwebservices.com/AWSSDKforPHP/latest/#m=AmazonS3/get_object_list Quote Link to comment Share on other sites More sharing options...
isimpledesign Posted January 21, 2011 Author Share Posted January 21, 2011 hi Sorry i am using this class http://undesigned.org.za/2007/10/22/amazon-s3-php-class Maybe is the class you suggested has better functionality i should make a choice and switch to this. Thanks Quote Link to comment Share on other sites More sharing options...
salathe Posted January 21, 2011 Share Posted January 21, 2011 Did you read the documentation for the class that you're using? You can restrict the objects returned from getBucket() by specifying a prefix. See http://undesigned.org.za/2007/10/22/amazon-s3-php-class/documentation#getBucket Quote Link to comment Share on other sites More sharing options...
isimpledesign Posted January 21, 2011 Author Share Posted January 21, 2011 Hi salathe Sorry feel abit stupid now got it working fine i did read the documentation but didnt understand it fully thanks alot for the reply, all working great Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.