mercredi 23 septembre 2015

Amazon s3 SDK php endpoint error occur

I was getting list of object from a bucket but it getting error of endpoint.

define('AWS_KEY', 'xxxxxx');
define('AWS_SECRET_KEY', 'x+x/xxxxxxxx/');
define('AWS_CANONICAL_ID','xx');
define('AWS_CANONICAL_NAME', 'xxxxx');
$HOST = 's3.amazonaws.com';
require_once 'php_plugins/aws/v1/sdk.class.php';

$Connection = new AmazonS3(array(
 'key' => AWS_KEY,
 'secret' => AWS_SECRET_KEY,
 'canonical_id' => AWS_CANONICAL_ID,
 'canonical_name' => AWS_CANONICAL_NAME,
));

$ListResponse = $Connection->list_buckets();
$Buckets = $ListResponse->body->Buckets->Bucket;
foreach ($Buckets as $Bucket) {
    echo $Bucket->Name . "\t" . $Bucket->CreationDate . "\n";
    $response = $Connection->list_objects($Bucket->Name);
}

I am getting response.

[body] => CFSimpleXML Object
    (
        [Code] => PermanentRedirect
        [Message] => The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
        [Bucket] => pics.online.com
        [Endpoint] => pics.online.com.s3.amazonaws.com
        [RequestId] => 5F102571A54DA3BA
        [HostId] => tBBxwxfUbdlV+m1R/Z9BnjLViyjROdzXrhPfc28WHaZYo/1zAwof2C0G5CVpZvkP8oZERTL0CD8=
    )

[status] => 301

I think error is in URL code call "host name/bucket name" http://ift.tt/1Kuw71L it should call http://ift.tt/1KNVMnr

can you anyone tell me how to change this path for amazon s3 PHP?

Aucun commentaire:

Enregistrer un commentaire