laravel中使用http如何分块下载大文件
我想使用http服务(底层是guzzle)分块下载文件(文件比较大,不分块可能会出错),但是没有搜到guzzle如何分块下载
以下是下载代码:
// 下载
$response = Http::withoutVerifying()->get($service->getDownloadUrl($this->recording));
// 下载失败
if (!$response->ok()) {
return null;
}
// Log::info($response->header('content-disposition'));
// 存储文件
$file_path = 'tenant_' . tenant()->id . '/callcenter/' . date('Ymd') . '/' . Str::random(40) . '.wav';
Storage::disk($this->disk)->put($file_path, $response->body());
推荐文章: