[英]Upload Progress percent in ajax upload to S3 bucket using the php-sdk with Mulitpart upload
I am trying to upload a video file to S3 bucket using the PHP-SDK and a multipart upload. 我正在尝试使用PHP-SDK和分段上传将视频文件上传到S3存储桶。 I managed to make it work via ajax already, but I want to know how to calculate and return the progress?
我已经设法通过ajax使它工作,但是我想知道如何计算并返回进度? I did a lot of research already but have not found any solutions yet.
我已经做了很多研究,但是还没有找到任何解决方案。
Any help highly appreciated. 任何帮助,高度赞赏。
Here's an example using putObject
, which can be converted into MultipartUpload: 这是一个使用
putObject
的示例,可以将其转换为MultipartUpload:
$client = new S3Client(/* config */);
$result = $client->putObject([
'Bucket' => 'bucket-name',
'Key' => 'bucket-name/file.ext',
'SourceFile' => 'local-file.ext',
'ContentType' => 'application/pdf',
'@http' => [
'progress' => function ($downloadTotalSize, $downloadSizeSoFar, $uploadTotalSize, $uploadSizeSoFar) {
printf(
"%s of %s downloaded, %s of %s uploaded.\n",
$downloadSizeSoFar,
$downloadTotalSize,
$uploadSizeSoFar,
$uploadTotalSize
);
}
]
]);
This is explained in the AWS docs - S3 Config section . AWS docs- S3 Config部分中对此进行了说明。 It works by exposing GuzzleHttp's
progress
property-callable, as explained in this SO answer . 它通过公开GuzzleHttp的
progress
属性可调用来工作,如本SO答案所述 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.