6
我想用Guzzle下載一個大文件並想跟蹤進度。我不知道是否必須通過流或使用RequestMediator。Gu 6 6下載進度
- 我嘗試訂閱事件curl.callback.progress,但PSR 7請求沒有事件分派器。
- 我試過on_stats,但回調只在最後被解僱。
- 進度用戶插件已經過時https://github.com/guzzle/progress-subscriber
我測試下面的代碼。
$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();
暗示將不勝感激。
完美,謝謝! – Laoneo