| @@ -81,9 +81,9 @@ | ||
| 81 | 81 | } catch (\Exception $e) { |
| 82 | 82 | return $response->redirect('/'); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - $this->downloadFile($file, $request, $streamedResponse); | |
| 85 | + $this->downloadFile($file, $request, $response, $streamedResponse); | |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * @param $file array |
| @@ -90,19 +90,24 @@ | ||
| 90 | 90 | * @param Request $request |
| 91 | 91 | * @param StreamedResponse $streamedResponse |
| 92 | 92 | * @return void |
| 93 | 93 | */ |
| 94 | - public function downloadFile(array $file, Request $request, StreamedResponse $streamedResponse) | |
| 94 | + public function downloadFile(array $file, Request $request, Response $response, StreamedResponse $streamedResponse) | |
| 95 | 95 | { |
| 96 | 96 | |
| 97 | + if($file['stream'] === false) { | |
| 98 | + return $response->json('Cannot read file, please check file permissions!', 422); | |
| 99 | + } | |
| 100 | + | |
| 97 | 101 | $streamedResponse->setCallback(function () use ($file) { |
| 98 | 102 | // @codeCoverageIgnoreStart |
| 99 | - set_time_limit(0); | |
| 103 | + @set_time_limit(0); | |
| 104 | + | |
| 100 | 105 | if ($file['stream']) { |
| 101 | 106 | while (! feof($file['stream'])) { |
| 102 | 107 | echo fread($file['stream'], 1024 * 8); |
| 103 | - ob_flush(); | |
| 104 | - flush(); | |
| 108 | + @ob_flush(); | |
| 109 | + @flush(); | |
| 105 | 110 | } |
| 106 | 111 | fclose($file['stream']); |
| 107 | 112 | } |
| 108 | 113 | // @codeCoverageIgnoreEnd |
| @@ -217,14 +222,14 @@ | ||
| 217 | 222 | $file = $tmpfs->readStream($uniqid); |
| 218 | 223 | |
| 219 | 224 | $streamedResponse->setCallback(function () use ($file, $tmpfs, $uniqid) { |
| 220 | 225 | // @codeCoverageIgnoreStart |
| 221 | - set_time_limit(0); | |
| 226 | + @set_time_limit(0); | |
| 222 | 227 | if ($file['stream']) { |
| 223 | 228 | while (! feof($file['stream'])) { |
| 224 | 229 | echo fread($file['stream'], 1024 * 8); |
| 225 | - ob_flush(); | |
| 226 | - flush(); | |
| 230 | + @ob_flush(); | |
| 231 | + @flush(); | |
| 227 | 232 | } |
| 228 | 233 | fclose($file['stream']); |
| 229 | 234 | } |
| 230 | 235 | $tmpfs->remove($uniqid); |