当前位置: 首页>>代码示例>>PHP>>正文


PHP S3Client::listBuckets方法代码示例

本文整理汇总了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]);
 }
开发者ID:ossinkine,项目名称:amazon-s3-client,代码行数:38,代码来源:AmazonS3Controller.php

示例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;
 }
开发者ID:pkdevboxy,项目名称:df-aws,代码行数:23,代码来源:S3FileSystem.php

示例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);
 }
开发者ID:myrichhub,项目名称:mssapi_php,代码行数:19,代码来源:IntegrationTest.php

示例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();
 }
开发者ID:Webiny,项目名称:Framework,代码行数:9,代码来源:S3.php

示例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>
开发者ID:PhyrexTsai,项目名称:Heroku-AWS-S3-php,代码行数:31,代码来源:fileupload.php

示例6: listBuckets

 /**
  * @return mixed
  */
 public function listBuckets()
 {
     $buckets = $this->s3Client->listBuckets();
     return $buckets["Buckets"];
 }
开发者ID:jlaso,项目名称:aws-s3-wrapper,代码行数:8,代码来源:S3Wrapper.php

示例7: listBuckets

 public function listBuckets()
 {
     $result = $this->s3->listBuckets();
     return $result['Buckets'];
 }
开发者ID:TheJester12,项目名称:s3upload_field,代码行数:5,代码来源:class.s3Facade.php

示例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>';
开发者ID:PhyrexTsai,项目名称:Heroku-AWS-EC2-S3-SQS-php,代码行数:31,代码来源:filedownload.php


注:本文中的Aws\S3\S3Client::listBuckets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。