Listing AWS S3 buckets using the PHP SDK

slifty

I'm using the PHP AWS SDK and would like to list all buckets available to me in S3.

I found a few different blocks of documentation that look promising:

Here's what I'm trying, using the AWS Service Builder to initialize an S3 client...

use Aws\Common\Aws;

// Instantiate an S3 client
$aws = Aws::factory(array( 'key' => "MY_KEY", 'secret' => "MY_SECRET"));
$s3 = $aws->get('s3');
$s3->get_bucket_list();

Unfortunately when I run the code I am told that it has no freakin' clue what "get_buckets_list" is. More specifically it says

Fatal error: Uncaught exception 'Guzzle\Common\Exception\InvalidArgumentException' with message 'Command was not found matching GetBucketList' in vendor/guzzle/guzzle/src/Guzzle/Service/Client.php:87

So my questions are as follows:

  • Am I looking at the wrong documentation?
  • Is there other documentation somewhere?
  • How do you get a list of buckets using the PHP AWS SDK?
Ja͢ck

The documentation for this call can be found here.

$result = $s3->listBuckets(array());
foreach ($result['Buckets'] as $bucket) {
    echo $bucket['Name'], PHP_EOL;
}

I suspect that you were mixing up two different API's :)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用PHP SDK列出AWS S3存储桶

来自分类Dev

AWS PHP SDK S3 RequestTimeTooSkewed错误

来自分类Dev

使用AWS PHP SDK访问Swisscom S3服务

来自分类Dev

清除AWS s3 php亚马逊sdk上的缓存

来自分类Dev

通过AWS PHP SDK向IAM用户授予对AWS S3文件的权限

来自分类Dev

使用AWS PHP SDK将文件安全传输到S3

来自分类Dev

AWS PHP SDK将文件上传到S3导致错误

来自分类Dev

从PHP AWS SDK设置S3对象的缓存控制HTTP标头

来自分类Dev

AWS s3在特定文件夹中下载所有文件-使用PHP SDK

来自分类Dev

AWS S3无法通过PHP SDK删除存储桶中的对象

来自分类Dev

通过PHP SDK为AWS S3创建CORS规则

来自分类Dev

AWS PHP SDK:限制预签名URL中的S3文件上传大小

来自分类Dev

AWS PHP SDK将文件上传到S3导致错误

来自分类Dev

AWS PHP S3 SDK中没有“ moveObject”功能

来自分类Dev

在Amazon AWS PHP SDK中为S3客户端设置适当的终端节点

来自分类Dev

有没有一种简单的方法可以减少AWS PHP SDK仅使用S3?

来自分类Dev

基本的AWS S3 PHP设置

来自分类Dev

Amazon S3签名不匹配-AWS SDK Java

来自分类Dev

AWS S3 Java SDK-拒绝访问

来自分类Dev

AWS-SDK S3 deleteObjects返回MalformedXML吗?

来自分类Dev

使用AWS C ++ SDK的分段上传S3

来自分类Dev

AWS S3 + Ruby SDK:如何列出存储桶

来自分类Dev

S3 putObject使用AWS-SDK失败

来自分类Dev

使用 AWS S3 Javascript SDK 加载新网页

来自分类Dev

在 AWS S3 SDK 中上传文件

来自分类Dev

删除多个对象Amazon s3 PHP SDK

来自分类Dev

使用PHP SDK在Amazon S3上上传文件

来自分类Dev

Amazon S3客户使用PHP SDK提供的加密

来自分类Dev

删除多个对象Amazon s3 PHP SDK