AWS S3批量上传从本地主机的PHP错误批量、错误、主机、上传

2023-09-11 09:07:00 作者:叆叇若紫

我想为批次/批量(XAMPP)上传从本地主机到我的 S3 桶。 它似乎工作约6个项目,然后我得到一个错误信息: 卷曲错误称无法发送网络数据。从的 http://curl.haxx.se/libcurl/c/libcurl-errors.html

I am trying to batch/bulk upload from localhost (xampp) to my S3 bucket. It seems to work for about 6 items then i get an error message: The cURL error says 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。它从一个目录,并从该循环我想批量上传这些项目映像的列表,以 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有消息弧线资源:资源ID#149;卷曲的错误:无法连接到mybucket.s3.amazonaws.com:443;没有错误(卷曲错误code 7)。见http://curl.haxx.se/libcurl/c/libcurl-errors.html为C $ CS错误$的说明。在D:\ XAMPP \ htdocs中\ SDK-1.5.14 \ lib目录\ requestcore \ requestcore.class.php线902 cURL_Multi_Exception:卷曲资源:资源ID#149;卷曲的错误:无法连接到prayerbucket.s3.amazonaws.com:443~~V;没有错误(卷曲错误code 7)。见http://curl.haxx.se/libcurl/c/libcurl-errors.html的错误codeS的解释。在D:\ XAMPP \ htdocs中\ SDK-1.5.14 \ lib目录\ requestcore \ requestcore.class.php线902

update: after making changes to congig.inc.php i am now getting error messages: 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

推荐答案

批量试限量:

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