PHP AWS S3 cURL错误6:无法解析主机

时间:2018-01-15 18:26:43

标签: php amazon-web-services amazon-s3

我正在尝试跨S3存储桶移动文件,并且在运行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

我无法弄清楚为什么错误消息中的网址为https://60_071fbf25-8654-4cef-a184-ecb241c1dfcf_20180115175327.wav时应该是https://s3.us-west-2.amazonaws.com/my-bucket-name/60_071fbf25-8654-4cef-a184-ecb241c1dfcf_20180115175327.wav

这是我的代码:

$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
]);

1 个答案:

答案 0 :(得分:0)

发现我用来设置Bucket内容和CopySource的bucket部分的环境变量没有在我正在使用的守护进程作业运行器中设置。确保设置这些环境变量可以解决问题。 :)