-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuckets.php
More file actions
37 lines (29 loc) · 757 Bytes
/
buckets.php
File metadata and controls
37 lines (29 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
include 'common.php';
global $settings;
global $cache;
use Aws\S3\S3Client;
$client = S3Client::factory(array(
'key' => $settings['s3']['key'],
'secret' => $settings['s3']['secret'],
'region' => $settings['s3']['region']
));
header('Content-Type: application/json');
$jsonBuckets = $cache->get("buckets");
if ($jsonBuckets != null)
{
echo json_encode($jsonBuckets);
return;
$buckets = $client->listBuckets();
$jsonBuckets = array();
foreach ($buckets['Buckets'] as $bucket)
{
$bucketData = array();
foreach ($object as $key => $value) {
$bucketData[$key] = $value;
}
array_push($jsonBuckets, $bucketData);
}
$cache->set("buckets", $jsonBuckets,6000);
echo json_encode($jsonBuckets);
?>