mardi 6 janvier 2015

read contents of file stored in s3 bucket

I am working on a project which requires searching of the contents of files (json) stored in an s3 bucket I can read the list of objects in the bucket but now want to read the elements in the files for searching here's what I have thus far :



use Aws\S3\S3Client;

// Establish connection with an S3 client.
$client = S3Client::factory(array(

'key' => AWS_KEY,
'secret' => AWS_SECRET_KEY
));

// list owned buckets


//$blist = $client->listBuckets();
//echo " Buckets belonging to " . $blist['Owner']['ID'] . ":\n";
//foreach ($blist['Buckets'] as $b) {
//echo "{$b['Name']}\t{$b['CreationDate']}\n";
//}


$bucketname ='cirrushq-config-updates';
$o_iter = $client->getIterator('ListObjects', array(
'Bucket' => $bucketname
));
foreach ($o_iter as $o) {
echo "{$o['Key']}\t{$o['Size']}\t{$o['LastModified']}\n";
}




Aucun commentaire:

Enregistrer un commentaire