尝试使用PHP SDK v2将PHP 7G文件上传到S3(PHP 5.5不可用)。小于5G的文件上传效果很好,但是分段上传从未起作用。在上传完成之前,它们总是没有任何消息或错误。
我有完整的S3访问权限。尝试了一堆不同的东西无济于事。
代码并不特别:
$uploader = UploadBuilder::newInstance()
->setBucket($bucket_nm)
->setKey($key)
->setMinPartSize(100 * 1024 * 1024)
->setConcurrency(1)
->setSource($src_path)
->setClient($s3)
->build();
try {
$uploader->getEventDispatcher()->addListener(
'multipart_upload.after_part_upload',
function($event) {
$msg = $event['state']->count() . ' parts uploaded.';
echo "$msg<br />";
WriteToLog($msg);
}
);
$uploader->upload();
$msg = 'Upload complete.';
} catch (MultipartUploadException $e) {
$uploader->abort();
$msg = 'Upload failed. ' . $e->getMessage() . '.';
}
echo "$msg<br />";
WriteToLog($msg);
答案 0 :(得分:0)
您需要应用这些try catch代替您的中止或上传过程
// Perform the upload. Abort the upload if something goes wrong
try {
$uploader->upload();
echo "Upload complete.\n";
} catch (MultipartUploadException $e) {
$uploader->abort();
echo "Upload failed.\n";
}