Skip to content

Commit

Permalink
[6.x] Fix memory usage on downloading large files (#31163)
Browse files Browse the repository at this point in the history
* fix memory usage on downloading large files

* Update FilesystemAdapter.php

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
sebsel and taylorotwell committed Jan 20, 2020
1 parent 6553d59 commit f239c07
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Illuminate/Filesystem/FilesystemAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down

0 comments on commit f239c07

Please sign in to comment.