PHP error AWS SDK 3: AWS HTTP error: cURL 6 error: failed to resolve host: s3.oregon.amazonaws.com

I am trying to connect to a bucket of SDK version 3.

But I get the following error:

PHP Fatal error: exception "Aws \ S3 \ Exception \ S3Exception" with the message "Runtime error" PutObject "at" https://s3.oregon.amazonaws.com/my-buekct-test/hello_world.txt "; AWS HTTP error : cURL 6 error: failed to resolve host: s3.oregon.amazonaws.com (see http://curl.haxx.se/libcurl/c/libcurl-errors.html ) '

This is my code, 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 am using AWS centos, php 5.5.21, apache 2.4.10

Could you indicate where I made a mistake?

+4
source share
1

,

<?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',// ,

aws : http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region

, !

+4

Source: https://habr.com/ru/post/1657458/


All Articles