I have following Amazon s3 configuration:
$Connection = new S3Client(array(
'version' => 'latest',
'region' => 'custom-region',
'endpoint' => 'http://mydomine.com',
'credentials' => [
'key' => AWS_KEY,
'secret' => AWS_SECRET_KEY,
// 'token' => false,
//'canonical_id' => AWS_CANONICAL_ID,
// 'canonical_name' => AWS_CANONICAL_NAME,
]
));
But calling this:
print_r($Connection->listBuckets());
I got:
PHP Fatal error: Uncaught exception 'Aws\S3\Exception\S3Exception' with message 'Error executing "ListBuckets" on "http://mydomine.com"; AWS HTTP error: Client error: 400 InvalidArgument (client): -
InvalidArgument
'exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: 400' in /home/kristineg/public_html/ocr/scanning/vendor/guzzlehttp/guzzle/src/Middleware.php:69 Stack trace: 0 /home/kristineg/public_html/ocr/scanning/vendor/guzzlehttp/promises/src/Promise.php(199): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) 1 /home/kristineg/public_html/ocr/scanning/vendor/guzzlehttp/promises/src/Promise.php(152): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) 2 /home/kristineg/public_html/ocr/scanning/vendor/guzzlehttp/promises/src/TaskQueue.php(60): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}() 3 /home/kristineg/public_html/ocr/scanning/vendor/guzzlehttp/gu in /home/kristineg/public_html/ocr/scanning/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php on line 152
As I understand, client is not configured correctly, but I can't imagine what exactly :(
Maybe somebody has any idea?
p.s. installed via composer like:
{
"require": {
"aws/aws-sdk-php": "^3.3",
"doctrine/cache": "^1.4",
"aws/aws-sdk-php-resources": "^0.3.0"
}
}
I'll go with older version, here I don't need to specify region. :)
$client = S3Client::factory([
'key' => Yii::$app->params['amazonS3']['accessKey'],
'secret' => Yii::$app->params['amazonS3']['secretKey'],
'base_url' => Yii::$app->params['amazonS3']['endpoint'],
]);