From f239c07cacb3d77daa3e6226ddc15547ddbf4795 Mon Sep 17 00:00:00 2001 From: Sebastiaan Andeweg Date: Mon, 20 Jan 2020 17:50:38 +0100 Subject: [PATCH] [6.x] Fix memory usage on downloading large files (#31163) * fix memory usage on downloading large files * Update FilesystemAdapter.php Co-authored-by: Taylor Otwell --- src/Illuminate/Filesystem/FilesystemAdapter.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Filesystem/FilesystemAdapter.php b/src/Illuminate/Filesystem/FilesystemAdapter.php index 8057b219c8ae..f5eb6bfba074 100644 --- a/src/Illuminate/Filesystem/FilesystemAdapter.php +++ b/src/Illuminate/Filesystem/FilesystemAdapter.php @@ -162,7 +162,11 @@ public function response($path, $name = null, array $headers = [], $disposition $response->setCallback(function () use ($path) { $stream = $this->readStream($path); - fpassthru($stream); + + while (! feof($stream)) { + echo fread($stream, 2048); + } + fclose($stream); });