How do I get the progress of a multipart uploader?
This is what I have and the progress callback is never called. Is it possible to get progress through the PHP SDK?
$uploader = new MultipartUploader($s3Client, $uploadedFile->getRealPath(), [
'bucket' => env('AWS_BUCKET'),
'key' => $filename,
'@http' => [
'progress' => function ($expectedDl, $dl, $expectedUl, $ul) {
// This never gets called
}
]
]);
I ended up finding a solution on my own. You pass a "params" key in the configuration array parameter containing the @http progress event callback.
params: (array) An array of key/value parameters that will be applied to each of the sub-commands run by the uploader as a base.
$uploader = new MultipartUploader($s3Client, $uploadedFile->getRealPath(), [
'bucket' => env('AWS_BUCKET'),
'key' => $filename,
'params' => [
'@http' => [
'progress' => function ($expectedDl, $dl, $expectedUl, $ul) {
// This gets called
}
]
]
]);
First try was close, but I wish this feature was more visible in guides as progress bars are a common UI element.
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.