Guzzle 流式下载数据/图片
use GuzzleHttp\Client;
$client = new Client();
$response = $client->get('https://baidu.com/?p=%E6%B5%8B%E8%AF%95', ['stream' => true]);
$filePath = storage_path("image/".time().".jpg");
$resource = fopen($filePath, "w+");
while (!$response->getBody()->eof()) {
$data = $response->getBody()->read(100);
fputs($resource, $data);
$this->line($data);
}
fclose($resource);
标签:resource,filePath,流式,Guzzle,PHP,data,response
From: https://www.cnblogs.com/jing1208/p/17406097.html