I want to download a large file with Guzzle and want to track the progress. I don't know if I have to pass a stream or use the RequestMediator somehow.
I'm testing the following code.
$dl = 'http://archive.ubuntu.com/ubuntu/dists/wily/main/installer-amd64/current/images/netboot/mini.iso';
$client = new Client([]);
$request = new GuzzleHttp\Psr7\Request('get', $dl);
$promise = $this->client->sendAsync($request, [
'sink' => '/tmp/test.bin'
]);
$promise->then(function (Response $resp) use ( $fs) {
echo 'Finished';
}, function (RequestException $e) {
});
$promise->wait();
An hint would be appreciated.
Though, its not mentioned within the documentation, you can use the "progress" request option.
References to it can be found here.
$options = [
'progress' => function ($dl_total_size, $dl_size_so_far, $ul_total_size, $ul_size_so_far) {
// do something.
}
];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With