2013-10-11 53 views
0

我正尝试使用Amazon S3来存储我的图像。 我所做到目前为止通过PEAR安装AWS SDK(链接:http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/installation.htmlAmazon S3基本操作不起作用

然后我去了第二个步骤,创建客户端:

<?php 

// Include the SDK using the Composer autoloader 
require 'vendor/autoload.php'; 

use Aws\S3\S3Client; 

// Instantiate the S3 client with your AWS credentials and desired AWS region 
$client = S3Client::factory(array(
    'key' => 'your-aws-access-key-id', 
    'secret' => 'your-aws-secret-access-key', 
)); 

我的按键设置是否正确......。

然后我想创建这样一个桶来测试这一切:

$bucket = 'my-bucket'; 
try{ 
    $result = $client->createBucket(array(
     'Bucket' => $bucket 
    )); 

    // Wait until the bucket is created 
    $client->waitUntil('BucketExists', array('Bucket' => $bucket)); 
} 
catch(Exception $e){ 
    var_dump($e->getMessage()); 
} 

但我总是得到这样的错误:

The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.

我觉得我的SDK安装不正确.. 。 谁能帮我这个?我使用的是无业游民,所以我在我的根文件夹安装了AWS SDK使用此命令:

sudo pear -D auto_discover=1 install pear.amazonwebservices.com/sdk

我是安装好消息。

我也做了我的$客户端的var_dump。我的回应链接:http://pastebin.com/KqkEiKGs
现在不,如果你用的东西吧...(我的按键被隐藏)

回答

2

你的错误消息指出它 - 你试图使用不唯一名称对于你的水桶,你应该使用更多独特的名字。而且,是的,存储桶名称必须是,在所有亚马逊S3(不仅是您的帐户)中都是唯一的。您可以阅读更多关于here的信息。