gpt4 book ai didi

PHP AWS SDK 3 错误 : AWS HTTP error: cURL error 6: Could not resolve host: s3. oregon.amazonaws.com

转载 作者:可可西里 更新时间:2023-10-31 22:40:39 24 4
gpt4 key购买 nike

我正在尝试连接到 AWS 版本 3 SDK 存储桶。

但是,我收到以下错误:

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"; AWS HTTP error: cURL error 6: Could not resolve host: s3.oregon.amazonaws.com (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)'

这是我的代码,很简单。

<?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'];

我正在使用 AWS centos、php 5.5.21、apache 2.4.10

你能帮我指出我错在哪里吗?

最佳答案

尝试使用下面的代码,你只需要更改区域

<?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

您可以从这里找到aws 的区域信息:http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region

希望这会有所帮助!

关于PHP AWS SDK 3 错误 : AWS HTTP error: cURL error 6: Could not resolve host: s3. oregon.amazonaws.com,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39991103/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com