2011-07-17 50 views
2

使麻煩使用我試圖將圖像上傳到S3存儲桶。不幸的是,我收到了一個奇怪的錯誤,無法在Google上找到任何東西。cURL與亞馬遜SDK使用create_object

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

當執行腳本中,我得到以下信息:

Fatal error: Uncaught exception 'RequestCore_Exception' with message 'cURL resource: Resource id #20; cURL error: select/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 

任何想法? cURL在其他文件中工作正常。

+0

'55 =無法發送網絡data.'。你確定curl指向的url是有效的嗎? – Wrikken

回答

-1

我認爲這個問題來自於舊版本的OpenSSL或cURL。一個變通辦法,幫助我解決這個問題是使用這樣的:

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

的curlopts標誌告訴S3的捲曲包裝不重用其創建的任何SSL連接。另一個可能的解決方案,通過https://forums.aws.amazon.com/thread.jspa?threadID=63918,建議使用disable_ssl()方法,這對我來說是一個非啓動器。

1

嘗試

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