Amazon S3 PHP image save curl error
I am trying to save an image to amazon's S3 cloud service using the s3 sdk provided by amazon. The code is actually very straight forward, this is the call in my code:
include_once "s3/sdk.class.php";
$s3 = new AmazonS3();
$file = $_FILES['userfile']['tmp_name'];
$name = $netid . "_splash.png";
$bucket = 'gw_splash';
$response = $s3->create_object($bucket, $name, array(
'fileUpload' => $file));
However, I do not think this call is the problem. When I run the code on a local WAMP server everything works fine. It is when I move it to the remote web server, running php5.2 and centOS 5.5 that I run into problems. I end up seeing this error in the logs:
[Thu Mar 24 11:38:57 2011] [error] [client 204.11.231.186] PHP Fatal error: Uncaught exception 'RequestCore_Exception' with message 'cURL resource: Resource id #61;
cURL error: select/poll returned error (55)' in /var/www/admin/system/application/controllers/s3/lib/requestcore/requestcore.class.php:795\nStack trace:\n#0 /var/www/admin/system/application/controllers/s3/services/s3.class.php(703):
RequestCore->send_request()\n#1 /var/www/admin/system/application/controllers/s3/services/s3.class.php(1196):
AmazonS3->authenticate('gw_splash', Array)\n#2 /var/www/admin/system/application/controllers/appdetails.php(224): AmazonS3->create_object('gw_splash', '22182_splash.pn...', Array)\n#3 [internal function]:
Appdetails->do_upload()\n#4 /var/www/admin/system/codeigniter/CodeIgniter.php(236): call_user_func_array(Array, Array)\n#5 /var/www/admin/index.php(115):
require_once('/var/www/admin/...')\n#6 {main}\n thrown in /var/www/admin/system/application/controllers/s3/lib/requestcore/requestcore.class.php on line 795, referer:
http://admin.isites.us/appdetails/?netid=22182&appType=1&appId=62981
Google tells me that error(55) is a network error. I know curl works fine as I have other php projects running that use curl just fine. I think that if I had php-curl.so in my extensions directory everything would work, (Besides the warning that it was loaded twice) but php-common comes with it already packaged together.
I really at a loss of what else to try since it DOES work locally, just not on the linux machine. I've been trying to go through the sdk provided by amazon to see if its trying to invoke php-curl in some weird way, but I haven't had any luck as of yet.
Any ideas would be 开发者_JS百科greatly appreciated!
I also received this error. After some checks with get_object instead of create_object I got the message The difference between the request time and the current time is too large. from S3. The server time was 20 minutes ahead. After setting the correct time get_object and also create_object worked correctly
you could check the curl version by running the compatibility test. So it should not be a problem. I saw another thread suggesting disable ssl or importing the ssl certificate into your porgram
A bit of time on Google led me to this question on AWS' support forums, in which an Amazon tech mentioned that some curl versions have been described as buggy. Check the output from curl_version
, perhaps you're using one of the possibly buggy versions.
精彩评论