amazon web services - PHP AWS S3 cURL error 6: Could not resolve host

563

I'm trying to move files across S3 buckets and am getting the following error when running CopyObject.

dev.ERROR: exception 'Aws\S3\Exception\S3Exception' with message 'Error executing "CopyObject" on "https://60_071fbf25-8654-4cef-a184-ecb241c1dfcf_20180115175327.wav"; AWS HTTP error: cURL error 6: Could not resolve host: 60_071fbf25-8654-4cef-a184-ecb241c1dfcf_20180115175327.wav

I can't figure out why the URL in the error message is https://60_071fbf25-8654-4cef-a184-ecb241c1dfcf_20180115175327.wav when it should be https://s3.us-west-2.amazonaws.com/my-bucket-name/60_071fbf25-8654-4cef-a184-ecb241c1dfcf_20180115175327.wav

Here's my code:

$s3 = \Aws\S3\S3Client::factory([
    'credentials' => [
       'key' => \Config::get('aws.s3_audio_upload.access_id'),
       'secret' => \Config::get('aws.s3_audio_upload.access_secret')
     ],
     'region' => 'us-west-2',
     'version' => '2006-03-01'
]);

$s3->copyObject([
    'Bucket' => 'metapop-hq-repo1',
    'CopySource' => 'metapop-inbox/60_071fbf25-8654-4cef-a184-ecb241c1dfcf_20180115175327.wav',
    'Key' => '60_071fbf25-8654-4cef-a184-ecb241c1dfcf_20180115175327.wav',
    'ACL' => $cannedAcl
]);
207

Answer

Solution:

Discovered that the environment variables I was using to set the contents of Bucket and the bucket part of CopySource were not set in the daemon job runner I am using. Ensuring that these environment variables were set fixed the problem. :)

People are also looking for solutions to the problem: php - return the value of a database column from its ID

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.