我正在尝试使用Guzzle将2GB文件上传到Amazon S3。我正在播放内容,我的代码如下所示:
$credentials = new Credentials( 'access_id', 'access_key');
$s3 = S3Client::factory(array(
'credentials' => $credentials
));;
try {
$s3->putObject(array(
'Bucket' => $bucket,
'Key' => $obect,
'Body' => (strlen($body) < 1000 && file_exists($body)) ? Guzzle\Http\EntityBody::factory(fopen($body, 'r+')) : $body,
'ACL' => $acl,
'ContentType' => $content_type
));
return true;
} catch (Aws\Exception\S3Exception $e) {
error_log($e -> getMessage() . ' ' . $e -> getTraceAsString());
return false;
}
现在我得到的错误是:
致命错误:未捕获的异常 带有消息'[curl] 28的'Guzzle \ Http \ Exception \ CurlException': 操作在30000毫秒后超时,0个-1个字节 收到[url] https://xxxxx.s3.amazonaws.com/6e12e321-adac-42a0-a932-8f345f9dd9c6” 在
如何使用Guzzle修改curl的超时?
答案 0 :(得分:2)
您可以通过以下方式设置卷曲选项:
$s3->putObject(array(
'Bucket' => '...',
'Key' => '...',
'Body' => '...',
'ACL' => '...',
'ContentType' => '...',
'curl.options' => array(
CURLOPT_TIMEOUT => 10,
CURLOPT_CONNECTTIMEOUT => 15
)
));
或试试这个:
$s3->getConfig()->set('curl.options', array(
CURLOPT_TIMEOUT => 10,
CURLOPT_CONNECTTIMEOUT => 15
)
);