How to use HttpClient to fetch remote file and save in directory inside app?

$fileUrl = 'https://example.com/file.xml.gz';
$http = new Client();
$response = $http->get($fileUrl,[], ['type' => 'xml', 'timeout' => 600]);
$xml = $response->xml;
....

How to use HttpClient to fetch remote file and save in directory inside app?

    $fileUrl = 'https://example.com/file.xml.gz';
    $http = new Client();
    $response = $http->get($fileUrl);
    file_put_content('file.xml.gz', $response->body);

You can get XML after unzip.
BR.

Thanks, but in this case that not work. I use Guzzle Client and now all woking.