[英]getting error AWS HTTP error: cURL error 6: when creation bucket using 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.我正在使用自己的云存储 Rados s3 服务器并尝试使用 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\\S3\\Exception\\S3Exception”,消息为“在“ http://pankaj.XXX.XX.XX.XXX/ ”上执行“CreateBucket”时出错; AWS HTTP error: cURL error 6: Could not resolve host: pankaj.XXX.XX.XX.XXX; AWS HTTP 错误:cURL 错误 6:无法解析主机: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名称或服务未知(参见http://curl.haxx.se/libcurl/c/libcurl-errors.html )'在 /var/www/html/object/vendor/aws/aws-sdk-php/src/ WrappedHttpHandler.php 第 191 行
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
请在您的客户端连接'use_path_style_endpoint' => true
使用添加此键'use_path_style_endpoint' => true
Example :示例:
$s3Client = new S3Client([
'region' => 'us-west-2',
'version' => '2006-03-01',
'use_path_style_endpoint' => true
]);
Remove the endpoint
from the client configuration.从客户端配置中删除endpoint
。
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";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.