]> BookStack Code Mirror - bookstack/commitdiff
Fixed streamed outputs in more extreme scenarios
authorDan Brown <redacted>
Sat, 2 Apr 2022 17:42:15 +0000 (18:42 +0100)
committerDan Brown <redacted>
Sat, 2 Apr 2022 17:42:15 +0000 (18:42 +0100)
Fixes hitting memory limits where downloaded file sizes are much greater
than memory limit. Stopping and flushing output buffer seemed to stop
limits causing issues when fpassthru is used.
Tested with 24M memory limit and 734M file

app/Http/Controllers/Controller.php

index ae1f4e4ba732e103cb3f9e332d0883b482385973..4c979c26a1ac1526f46e9afcf37d9414fb2e5dd9 100644 (file)
@@ -127,6 +127,7 @@ abstract class Controller extends BaseController
     protected function streamedDownloadResponse($stream, string $fileName): StreamedResponse
     {
         return response()->stream(function() use ($stream) {
+            ob_end_clean();
             fpassthru($stream);
             fclose($stream);
         }, 200, [