diff --git a/core/includes/file.inc b/core/includes/file.inc index 534d211..cbeb8a7 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -9,7 +9,7 @@ use Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpFoundation\StreamedResponse; +use Symfony\Component\HttpFoundation\BinaryFileResponse; /** * Stream wrapper bit flags that are the basis for composite types. @@ -1306,28 +1306,6 @@ function file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EX } /** - * Transfers a file to the client using HTTP. - * - * Pipes a file through Drupal to the client. - * - * @param $uri - * String specifying the file URI to transfer. - * @param $headers - * An array of HTTP headers to send along with file. - */ -function file_transfer($uri, $headers) { - return new StreamedResponse(function() use ($uri) { - // Transfer file in 1024 byte chunks to save memory usage. - if (file_exists($uri) && $fd = fopen($uri, 'rb')) { - while (!feof($fd)) { - print fread($fd, 1024); - } - fclose($fd); - } - }, 200, $headers); -} - -/** * Page callback: Handles private file transfers. * * Call modules that implement hook_file_download() to find out if a file is @@ -1355,7 +1333,7 @@ function file_download() { } } if (count($headers)) { - return file_transfer($uri, $headers); + return new BinaryFileResponse($uri, 200, $headers); } throw new AccessDeniedHttpException(); } diff --git a/core/modules/image/image.module b/core/modules/image/image.module index d7b02d0..f6b5eda 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -6,7 +6,7 @@ */ use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\StreamedResponse; +use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Drupal\Component\Uuid\Uuid; use Drupal\file\Plugin\Core\Entity\File; @@ -655,7 +655,7 @@ function image_style_deliver($style, $scheme) { 'Content-Type' => $image->info['mime_type'], 'Content-Length' => $image->info['file_size'], ); - return file_transfer($uri, $headers); + return new BinaryFileResponse($uri, 200, $headers); } else { watchdog('image', 'Unable to generate the derived image located at %path.', array('%path' => $derivative_uri)); diff --git a/core/modules/update/tests/modules/update_test/update_test.module b/core/modules/update/tests/modules/update_test/update_test.module index 078bcf5..91a5ac9 100644 --- a/core/modules/update/tests/modules/update_test/update_test.module +++ b/core/modules/update/tests/modules/update_test/update_test.module @@ -1,7 +1,7 @@