PHP s3多部分上载内存问题

PHP s3多部分上载内存问题,php,amazon-s3,Php,Amazon S3,我有一个将8GB文件上传到服务器的代码。我遇到的问题似乎是内存问题,因为我的服务器只有4GB的ram。我的上传脚本是: $s3 = S3Client::factory(array( 'credentials' => $credentials ));; // 2. Create a new multipart upload and get the upload

我有一个将8GB文件上传到服务器的代码。我遇到的问题似乎是内存问题,因为我的服务器只有4GB的ram。我的上传脚本是:

 $s3 = S3Client::factory(array(
                        'credentials' => $credentials
                ));;

                        // 2. Create a new multipart upload and get the upload ID.
                    $response = $s3->createMultipartUpload(array(
                        'Bucket' => $bucket,
                        'Key'    => $obect,
                        //'Body'   => (strlen($body) < 1000 && file_exists($body)) ? Guzzle\Http\EntityBody::factory(fopen($body, 'r+')) : $body,
                        'ACL'    => $acl,
                        'ContentType' => $content_type,
                        'curl.options' => array(
                                CURLOPT_TIMEOUT => 12000,
                        )
                    ));

                        $uploadId = $response['UploadId'];

                        // 3. Upload the file in parts.
                        $file = fopen($body, 'r');
                        $parts = array();
                        $partNumber = 1;

                        while (!feof($file)) {
                            $result = $s3->uploadPart(array(
                                'Bucket'     => $bucket,
                                'Key'        => $obect,
                                'UploadId'   => $uploadId,
                                'PartNumber' => $partNumber,
                                'Body'       => fread($file, 10 * 1024 * 1024),
                            ));
                            $parts[] = array(
                                'PartNumber' => $partNumber++,
                                'ETag'       => $result['ETag'],
                            );
                        }

  $result = $s3->completeMultipartUpload(array(
                            'Bucket'   => $bucket,
                            'Key'      => $obect
                            ,
                            'UploadId' => $uploadId,
                            'Parts'    => $parts,
                        ));

                        $url = $result['Location'];

                        return true;
                } catch (Aws\Exception\S3Exception $e) {
                        error_log($e -> getMessage() . ' ' . $e -> getTraceAsString());
                        return false;
                } catch (Exception $e) {
                        error_log($e -> getMessage() . ' ' . $e -> getTraceAsString());
                        return false;
                }
$s3=S3Client::factory(数组)(
“凭据”=>$credentials
));;
// 2. 创建新的多部分上载并获取上载ID。
$response=$s3->createMultipartUpload(数组(
“Bucket”=>$Bucket,
“Key”=>$obect,
//“Body”=>(strlen($Body)<1000&&file_存在($Body))?Guzzle\Http\EntityBody::factory(fopen($Body,'r+'):$Body,
“ACL”=>$ACL,
“ContentType”=>$content\u type,
'curl.options'=>数组(
CULLOPT_超时=>12000,
)
));
$uploadId=$response['uploadId'];
// 3. 将文件分部分上传。
$file=fopen($body,'r');
$parts=array();
$partNumber=1;
而(!feof($file)){
$result=$s3->uploadPart(数组)(
“Bucket”=>$Bucket,
“Key”=>$obect,
'UploadId'=>$UploadId,
“PartNumber”=>$PartNumber,
“Body”=>fread($file,10*1024*1024),
));
$parts[]=数组(
“PartNumber”=>$PartNumber++,
'ETag'=>$result['ETag'],
);
}
$result=$s3->completeMultipartUpload(数组)(
“Bucket”=>$Bucket,
“Key”=>$obect
,
'UploadId'=>$UploadId,
“零件”=>$Parts,
));
$url=$result['Location'];
返回true;
}捕获(Aws\Exception\S3Exception$e){
错误日志($e->getMessage()。$e->GetRacesString());
返回false;
}捕获(例外$e){
错误日志($e->getMessage()。$e->GetRacesString());
返回false;
}

以前有人遇到过这个问题吗?如何解决内存问题?

实际问题是什么?api有任何错误或响应吗?没有,内存已满,CPU变为100,服务器扁平线