开发者

cURL making trouble with amazon SDK using create_object

I am trying to upload an image to a S3 bucket. Unfortunately I am getting a weird error and can't find anything on google.

$s3 = new AmazonS3();
$bucket = 'myBucket';
$fileResource = 'test.JPG';
$response = $s3->create_object($bucket, $filename, array('fileUpload' => $fileResource));
print_r($response);

When executing the script I get the following message:

Fatal error: Uncaught exception 'RequestCore_Exception' with message 'cURL resource: Resource id #20; cURL error: sele开发者_如何学运维ct/poll returned error (55)' in /home/myproject.com/public_html/aws/lib/requestcore/requestcore.class.php:817 Stack trace: #0 /home/myproject.com/public_html/aws/services/s3.class.php(688): RequestCore->send_request() #1 /home/myproject.com/public_html/aws/services/s3.class.php(1286): AmazonS3->authenticate('myBucket', Array) #2 /home/myproject.com/public_html/myScript.php(16): AmazonS3->create_object('myBucket', NULL, Array) #3 {main} thrown in /home/myproject.com/public_html/aws/lib/requestcore/requestcore.class.php on line 817

Any idea? cURL is working fine in other files.


Try

$file_path = 'test.JPG' ;
$file_resource = @fopen($file_path, 'r');

$content_type = CFMimeTypes::get_mimetype('.jpg');

$params = array( 'fileUpload' => $file_resource,
             'contentType' => $content_type); 

$response = $s3->create_object($bucket_name, $object_name, $params );


I think this problem comes out of having an older version of OpenSSL or cURL. A work-around that helped me deal with the problem is using this:

$response = $s3->create_object(
    $bucket,
    $filename,
    array(
        'fileUpload' => $fileResource,
        'curlopts' => array(CURLOPT_FORBID_REUSE => true),
    )
 );

The curlopts flag is telling S3's curl wrapper to not reuse any SSL connections that it creates. Another possible solution, via https://forums.aws.amazon.com/thread.jspa?threadID=63918, suggests using the disable_ssl() method, which was a non-starter for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜