[英]PHP AWS SDK 3 Error: AWS HTTP error: cURL error 6: Could not resolve host: s3.oregon.amazonaws.com
I'm trying to connect to an AWS version 3 SDK bucket. 我正在尝试连接到AWS版本3 SDK存储桶。
But, I receive the below error: 但是,我收到以下错误:
PHP Fatal error: Uncaught exception 'Aws\\S3\\Exception\\S3Exception' with message 'Error executing "PutObject" on " https://s3.oregon.amazonaws.com/my-buekct-test/hello_world.txt ";
PHP致命错误:未捕获异常'Aws \\ S3 \\ Exception \\ S3Exception',消息'错误执行“PutObject”on“ https://s3.oregon.amazonaws.com/my-buekct-test/hello_world.txt ”; AWS HTTP error: cURL error 6: Could not resolve host: s3.oregon.amazonaws.com (see http://curl.haxx.se/libcurl/c/libcurl-errors.html )'
AWS HTTP错误:cURL错误6:无法解析主机:s3.oregon.amazonaws.com(请参阅http://curl.haxx.se/libcurl/c/libcurl-errors.html )'
This is my code, just simple. 这是我的代码,很简单。
<?php
header('Content-Type: text/plain; charset=utf-8');
// Include the SDK using the Composer autoloader
require 'vendor/autoload.php';
$s3 = new Aws\S3\S3Client([
'region' => 'Oregon',
'version' => 'latest',
'credentials' => [
'key' => 'Enter the key',
'secret' => 'Enter the Secret key'
]
]);
// Send a PutObject request and get the result object.
$key = 'hello_world.txt';
$result = $s3->putObject([
'Bucket' => 'my-buekct-test',
'Key' => $key,
'Body' => 'this is the body!'
]);
// Print the body of the result by indexing into the result object.
echo $result['Body'];
I'm using AWS centos, php 5.5.21, apache 2.4.10 我正在使用AWS centos,php 5.5.21,apache 2.4.10
Could you help point out where did I go wrong? 你能指出我哪里出错吗?
Try with below code you need to change region only 尝试使用以下代码,您只需要更改区域
<?php
header('Content-Type: text/plain; charset=utf-8');
// Include the SDK using the Composer autoloader
require 'vendor/autoload.php';
$s3 = new Aws\S3\S3Client([
'region' => 'us-west-2',
'version' => 'latest',
'credentials' => [
'key' => 'Enter the key',
'secret' => 'Enter the Secret key'
]
]);
// Send a PutObject request and get the result object.
$key = 'hello_world.txt';
$result = $s3->putObject([
'Bucket' => 'my-buekct-test',
'Key' => $key,
'Body' => 'this is the body!'
]);
// Print the body of the result by indexing into the result object.
echo $result['Body'];
'region' => 'us-west-2', // this thing i only updated
'region'=>'us-west-2',//这件事我只更新了
you can find region information of aws from here : http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region 你可以在这里找到aws的地区信息: http : //docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
Hope this will help! 希望这会有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.