【问题标题】:AWS S3 batch upload from localhost php error从本地主机 php 错误的 AWS S3 批量上传
【发布时间】:2012-09-03 20:43:10
【问题描述】:

我正在尝试批量/批量从 localhost (xampp) 上传到我的 S3 存储桶。
它似乎适用于大约 6 个项目,然后我收到一条错误消息:

cURL 错误显示 Failed sending network data. from http://curl.haxx.se/libcurl/c/libcurl-errors.html

Fatal error: Uncaught exception 'cURL_Multi_Exception' with message 'cURL resource: Resource id #34; cURL error: SSL_write() returned SYSCALL, errno = 0 (cURL error code 55). See http://curl.haxx.se/libcurl/c/libcurl-errors.html for an explanation of error codes.' in D:\xampp\htdocs\path\to\my\files\sdk-1.5.14\lib\requestcore\requestcore.class.php on line 902

cURL_Multi_Exception: cURL resource: Resource id #34; cURL error: SSL_write() returned SYSCALL, errno = 0 (cURL error code 55). See http://curl.haxx.se/libcurl/c/libcurl-errors.html for an explanation of error codes. in D:\xampp\htdocs\path\to\my\files\sdk-1.5.14\lib\requestcore\requestcore.class.php on line 902

这是我的 php.ini 文件。它从目录中获取图像列表,我希望从该循环中将这些项目批量上传到S3

require_once('sdk-1.5.14/sdk.class.php');
$s3 = new AmazonS3();
//$s3->disable_ssl_verification(); //this didnt fix it

$folder = "./../"; 
$handle = opendir($folder); 

# Making an array of files in a directory to upload to S3
while ($file = readdir($handle)) 
{ 
        $files[] = $file; 
} 
closedir($handle);

foreach ($files as $file) { 
        $path_parts = pathinfo($file);
        if(isset($path_parts['extension']) && $path_parts['extension'] != '') {

                // local path
                $fileTempName = "D:/xampp/htdocs/path/to/my/files/";

                //batch
                $response = $s3->batch()->create_object('bucketname', "tempdirectory/" . $file, array(
                        'fileUpload' => fopen($fileTempName . $file, 'r'),
                        'acl' => AmazonS3::ACL_PUBLIC
                ));

        }

}
$s3->batch()->send();

更新: 在对congig.inc.php 进行更改后,我现在收到错误消息:

Fatal error: Uncaught exception 'cURL_Multi_Exception' with message 'cURL resource: Resource id #149; cURL error: Failed connect to mybucket.s3.amazonaws.com:443; No error (cURL error code 7). See http://curl.haxx.se/libcurl/c/libcurl-errors.html for an explanation of error codes.' in D:\xampp\htdocs\sdk-1.5.14\lib\requestcore\requestcore.class.php on line 902

cURL_Multi_Exception: cURL resource: Resource id #149; cURL error: Failed connect to prayerbucket.s3.amazonaws.com:443; No error (cURL error code 7). See http://curl.haxx.se/libcurl/c/libcurl-errors.html for an explanation of error codes. in D:\xampp\htdocs\sdk-1.5.14\lib\requestcore\requestcore.class.php on line 902

【问题讨论】:

  • 据我所知,您无法从 localhost 测试 amazon aw3。我不得不将我的文件上传到我的主机并尝试直播。
  • @Cyber​​Junkie 我明白了,你听说过任何解决方法吗?
  • 我也遇到这个错误,我尝试设置限制批处理队列 = 2
  • 我是这样创建的:$batch = new CFBatchRequest(2); $s3->批处理($批处理);但是需要多次调用 $s3->batch()->send() ;而且批量发送不好:(

标签: php amazon-s3 curl-multi


【解决方案1】:

尝试设置批次限制:

$batch = new CFBatchRequest(2); // only two instance at once

foreach ($files as $file) { 
        $path_parts = pathinfo($file);
        if(isset($path_parts['extension']) && $path_parts['extension'] != '') {

                // local path
                $fileTempName = "D:/xampp/htdocs/path/to/my/files/";

                // if batch, it have to return curl's resource
                $curl_handler = $s3->batch($batch)->create_object('bucketname', "tempdirectory/" . $file, array(
                        'fileUpload' => fopen($fileTempName . $file, 'r'),
                        'acl' => AmazonS3::ACL_PUBLIC
                ));

        }

}
// batch object send queue
$batch->send();

【讨论】:

    【解决方案2】:

    尝试在 config.inc.php 中将 'certificate_authority' 设置为 true。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-12
      • 2015-09-28
      • 2021-03-26
      • 2017-02-10
      • 1970-01-01
      • 1970-01-01
      • 2012-10-27
      • 2017-02-20
      相关资源
      最近更新 更多