我正在尝试将图像上传到S3存储桶。不幸的是,我得到一个奇怪的错误,在谷歌上找不到任何东西。
$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 :(得分: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 );
答案 1 :(得分:-1)
我认为这个问题来自于使用旧版本的OpenSSL或cURL。帮助我解决问题的解决方法就是使用它:
$response = $s3->create_object(
$bucket,
$filename,
array(
'fileUpload' => $fileResource,
'curlopts' => array(CURLOPT_FORBID_REUSE => true),
)
);
curlopts标志告诉S3的curl包装器不重用它创建的任何SSL连接。另一个可能的解决方案,通过https://forums.aws.amazon.com/thread.jspa?threadID=63918建议使用disable_ssl()方法,这对我来说是一个非启动方法。