Reputation: 222
I am using own cloud storage Rados s3 server and trying to create a bucket using 3.52 php AWS sdk. Following is the code I am running in my console:
require 'vendor/autoload.php';
use Aws\S3\S3Client;
use Aws\Credentials\CredentialProvider;
$Connection = new S3Client([
'region' => 'us-west-2',
'version' => 'latest',
'endpoint' => 'http://XXX.XX.XX.XXX',
'credentials' => [
'key' => 'xx',
'secret' => 'XX'
],
]);
//create a bucket
$promise =$Connection->createBucket(array('Bucket' => 'pankaj'));
I am getting below fatal error
Fatal error: Uncaught exception 'Aws\S3\Exception\S3Exception' with message 'Error executing "CreateBucket" on "http://pankaj.XXX.XX.XX.XXX/"; AWS HTTP error: cURL error 6: Could not resolve host: pankaj.XXX.XX.XX.XXX; Name or service not known (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in /var/www/html/object/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php on line 191
Upvotes: 2
Views: 3280
Reputation: 76
I think it's not accepting your end point which you define.
please use add this key in your client connection
'use_path_style_endpoint' => true
Example :
$s3Client = new S3Client([
'region' => 'us-west-2',
'version' => '2006-03-01',
'use_path_style_endpoint' => true
]);
Upvotes: 4
Reputation: 3245
Remove the endpoint
from the client configuration.
require 'vendor/autoload.php';
use Aws\S3\S3Client;
use Aws\Exception\AwsException;
$BUCKET_NAME='<BUCKET-NAME>';
//Create a S3Client
$s3Client = new S3Client([
'region' => 'us-west-2',
'version' => '2006-03-01'
]);
//Creating S3 Bucket
try {
$result = $s3Client->createBucket([
'Bucket' => $BUCKET_NAME,
]);
}catch (AwsException $e) {
// output error message if fails
echo $e->getMessage();
echo "\n";
}
Upvotes: 0