I am trying to upload a video file to S3 bucket using the PHP-SDK and a multipart upload. I managed to make it work via ajax already, but I want to know how to calculate and return the progress? 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:
$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 . It works by exposing GuzzleHttp's progress
property-callable, as explained in this SO answer .
Have you looked into these links.
http://codeseekah.com/2012/03/09/file-upload-progress-in-php-5-4/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.