本文整理汇总了PHP中Aws\S3\S3Client::listBuckets方法的典型用法代码示例。如果您正苦于以下问题:PHP S3Client::listBuckets方法的具体用法?PHP S3Client::listBuckets怎么用?PHP S3Client::listBuckets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aws\S3\S3Client
的用法示例。
在下文中一共展示了S3Client::listBuckets方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listAction
/**
* @param string $bucket
* @return string
*/
public function listAction($bucket)
{
$errors = [];
$buckets = [];
try {
$result = $this->s3Client->listBuckets();
$buckets = $result->get('Buckets');
} catch (S3Exception $e) {
$errors[] = sprintf('Cannot retrieve buckets: %s', $e->getMessage());
}
$objects = [];
if (!empty($bucket)) {
try {
$maxIteration = 10;
$iteration = 0;
$marker = '';
do {
$result = $this->s3Client->listObjects(['Bucket' => $bucket, 'Marker' => $marker]);
if ($result->get('Contents')) {
$objects = array_merge($objects, $result->get('Contents'));
}
if (count($objects)) {
$marker = $objects[count($objects) - 1]['Key'];
}
} while ($result->get('IsTruncated') && ++$iteration < $maxIteration);
if ($result->get('IsTruncated')) {
$errors[] = sprintf('The number of keys greater than %u, the first part is shown', count($objects));
}
} catch (S3Exception $e) {
$errors[] = sprintf('Cannot retrieve objects: %s', $e->getMessage());
}
}
return $this->twig->render('list.html.twig', ['selected_bucket' => $bucket, 'buckets' => $buckets, 'objects' => $objects, 'errors' => $errors]);
}
示例2: listContainers
/**
* List all containers, just names if noted
*
* @param bool $include_properties If true, additional properties are retrieved
*
* @throws \Exception
* @return array
*/
public function listContainers($include_properties = false)
{
$this->checkConnection();
if (!empty($this->container)) {
return $this->listResource($include_properties);
}
/** @noinspection PhpUndefinedMethodInspection */
$buckets = $this->blobConn->listBuckets()->get('Buckets');
$out = [];
foreach ($buckets as $bucket) {
$name = rtrim($bucket['Name']);
$out[] = ['name' => $name, 'path' => $name];
}
return $out;
}
示例3: testGetService
/**
* @depends testHeadBucket
*/
public function testGetService()
{
$result = $this->client->listBuckets();
$this->assertNotEmpty($result['Owner']);
$this->assertNotEmpty($result['Owner']['ID']);
$this->assertNotEmpty($result['Owner']['DisplayName']);
$this->assertNotEmpty($result['Buckets']);
$found = false;
foreach ($result['Buckets'] as $bucket) {
if ($bucket['Name'] == $this->bucket) {
$found = true;
break;
}
}
$this->assertTrue($found);
}
示例4: listBuckets
/**
* Returns a list of all buckets owned by the authenticated sender of the request.
* Available keys: Name, CreationDate
* @return mixed
*/
public function listBuckets()
{
return $this->instance->listBuckets();
}
示例5:
<?php
if ($message != '') {
?>
<p class="bg-warning"><?php
echo $message;
?>
</p>
<?php
}
?>
<form method="POST" action="" enctype="multipart/form-data">
<div class="form-group">
<label for="exampleInputFile">Choose Bucket</label>
<select name="bucket" class="form-control">
<?php
$buckets = $s3->listBuckets();
foreach ($buckets['Buckets'] as $bucket) {
echo '<option value="' . $bucket['Name'] . '">' . $bucket['Name'] . '</option>';
}
?>
</select>
</div>
<div class="form-group">
<label for="exampleInputFile">File upload</label>
<input type="file" name="uploadfile" id="exampleInputFile" class="form-control">
</div>
<input type="submit" name="submit" class="btn btn-primary" value="Upload Image" />
</form>
</div>
<div class="col-md-1"></div>
</div>
示例6: listBuckets
/**
* @return mixed
*/
public function listBuckets()
{
$buckets = $this->s3Client->listBuckets();
return $buckets["Buckets"];
}
示例7: listBuckets
public function listBuckets()
{
$result = $this->s3->listBuckets();
return $result['Buckets'];
}
示例8: explode
echo $message;
?>
</p>
<?php
}
?>
<table class="table">
<tr>
<th>Bucket</th>
<th>File Name</th>
<th>Download Link</th>
<th>Resized Image</th>
</tr>
<?php
$result = $s3->listBuckets();
foreach ($result['Buckets'] as $bucket) {
// Each Bucket value will contain a Name and CreationDate
if ($s3->doesObjectExist($bucket['Name'], SMALLIMAGELIST_FILE)) {
$txtfile = $s3->getObject(['Bucket' => $bucket['Name'], 'Key' => SMALLIMAGELIST_FILE]);
$txtbody = $txtfile['Body'];
$lines = explode(PHP_EOL, $txtbody);
foreach ($lines as $key) {
if (trim($key) != '') {
$tag = preg_split("/######/", $key);
echo '<tr>';
echo '<td>' . $bucket['Name'] . '</td>';
echo '<td>' . $tag[1] . '</td>';
echo '<td><a href="' . S3_PATH . $bucket['Name'] . '/' . $tag[1] . '">Click</a></td>';
echo '<td><a href="' . S3_PATH . $bucket['Name'] . '/' . $tag[2] . '"><img src="' . S3_PATH . $bucket['Name'] . '/' . $tag[2] . '"/></a></td>';
echo '</tr>';