AWS S3从本地主机批量上载php错误

AWS S3从本地主机批量上载php错误,php,amazon-s3,curl-multi,Php,Amazon S3,Curl Multi,我正在尝试从本地主机(xampp)将批处理/批量上传到我的S3bucket。 它似乎适用于大约6个项目,然后我收到一条错误消息: cURL错误表示发送网络数据失败。来自 及 这是我的php。它从一个目录中获取一个图像列表,我希望从该循环中批量将这些项目上传到S3 require_once('sdk-1.5.14/sdk.class.php'); $s3 = new AmazonS3(); //$s3->disable_ssl_verification(); //this didnt fix

我正在尝试从本地主机(xampp)将批处理/批量上传到我的
S3
bucket。
它似乎适用于大约6个项目,然后我收到一条错误消息:

cURL错误表示
发送网络数据失败。
来自

这是我的php。它从一个目录中获取一个图像列表,我希望从该循环中批量将这些项目上传到
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
进行更改后,我现在收到错误消息:

致命错误:未捕获的异常“cURL_Multi_exception”,消息为“cURL resource:resource id#149;cURL错误:无法连接到mybucket.s3.amazonaws.com:443;无错误(cURL错误代码7)。看见http://curl.haxx.se/libcurl/c/libcurl-errors.html 有关错误代码的解释,请参见D:\xampp\htdocs\sdk-1.5.14\lib\requestcore\requestcore.class.php中的第902行



cURL_Multi_异常:cURL资源:资源id#149;cURL错误:无法连接到rajerbucket.s3.amazonaws.com:443;无错误(cURL错误代码7)。看见http://curl.haxx.se/libcurl/c/libcurl-errors.html 有关错误代码的说明。在第902行的D:\xampp\htdocs\sdk-1.5.14\lib\requestcore\requestcore.class.php中

尝试在config.inc.php中将“certificate\u authority”设置为true。

尝试设置批次限制:

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

据我所知,您无法从localhost测试AmazonAW3。我必须将我的文件上传到我的主机并尝试直播。@CyberJunkie我明白了,你听说过任何解决方法吗?这就是我所知道的全部,我也遇到了这个错误,我尝试设置限制批处理队列=2我用这种方式创建:$batch=new CbatchRequest(2)$s3->批次($batch);但是需要多次调用$s3->batch()->send();批量发送不好:(
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();
$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();