I am trying to upload a 2GB File to Amazon S3 with Guzzle. I am streaming the content and my code look like this:
$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;
}
Now the error I am getting is this:
Fatal error: Uncaught exception 'Guzzle\Http\Exception\CurlException' with message '[curl] 28: Operation timed out after 30000 milliseconds with 0 out of -1 bytes received [url] https://xxxxx.s3.amazonaws.com/6e12e321-adac-42a0-a932-8f345f9dd9c6' in
How can I modify the timeout for curl with Guzzle?
You may set curl options by this way:
$s3->putObject(array(
'Bucket' => '...',
'Key' => '...',
'Body' => '...',
'ACL' => '...',
'ContentType' => '...',
'curl.options' => array(
CURLOPT_TIMEOUT => 10,
CURLOPT_CONNECTTIMEOUT => 15
)
));
Or try this:
$s3->getConfig()->set('curl.options', array(
CURLOPT_TIMEOUT => 10,
CURLOPT_CONNECTTIMEOUT => 15
)
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With