php - Guzzle 6 progress of download -
i want download large file guzzle , want track progress. don't know if have pass stream or use requestmediator somehow.
- i tried subscribing event curl.callback.progress, psr 7 request doesn't have event dispatcher.
- i tried on_stats, callback fired @ end.
- the progress subscriber plugin deprecated https://github.com/guzzle/progress-subscriber
i'm testing 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 appreciated.
though, not mentioned within documentation, can use "progress" request option.
references can found here.
$options = [ 'progress' => function ($dl_total_size, $dl_size_so_far, $ul_total_size, $ul_size_so_far) { // something. } ];
Comments
Post a Comment