doushi3322
doushi3322
2018-02-09 04:26
浏览 626
已采纳

获取错误AWS HTTP错误:cURL错误6:使用3.52 php sdk创建存储桶时

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

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dsoxcj7276
    dsoxcj7276 2018-02-12 06:27
    已采纳

    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
    

    ]);

    点赞 评论
  • dora0817
    dora0817 2018-02-09 06:06

    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 "
    ";
    }
    
    点赞 评论

相关推荐