gpt4 book ai didi

php - 从 localhost php 错误的 AWS S3 批量上传

转载 作者:搜寻专家 更新时间:2023-10-31 22:11:40 25 4
gpt4 key购买 nike

我正在尝试从本地主机 (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 :未捕获异常“cURL_Multi_Exception”,消息为“cURL 资源:资源 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_Exception:cURL 资源:资源 ID #149; cURL 错误:无法连接到 prayerbucket.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 行

最佳答案

尝试为批处理设置限制:

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

关于php - 从 localhost php 错误的 AWS S3 批量上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12253812/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com