Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a6f41f5

Browse files
[HttpFoundation] Add doc for File\Stream
1 parent fefc2f2 commit a6f41f5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

components/http_foundation.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,20 @@ It is possible to delete the file after the request is sent with the
518518
:method:`Symfony\\Component\\HttpFoundation\\BinaryFileResponse::deleteFileAfterSend` method.
519519
Please note that this will not work when the ``X-Sendfile`` header is set.
520520

521+
.. versionadded:: 3.3
522+
The ``Stream`` class has been introduced in Symfony 3.3.
523+
524+
If the size of the served file is unknown (e.g. because it's being generated on the fly,
525+
or because a PHP stream filter is registered on it, etc.), you can pass a ``Stream``
526+
instance to ``BinaryFileResponse``. This will disable ``Range`` and ``Content-Length``
527+
handling, switching to chunked encoding instead::
528+
529+
use Symfony\Component\HttpFoundation\BinaryFileResponse;
530+
use Symfony\Component\HttpFoundation\File\Stream;
531+
532+
$stream = new Stream('path/to/stream');
533+
$response = new BinaryFileResponse($stream);
534+
521535
.. note::
522536

523537
If you *just* created the file during this same request, the file *may* be sent

0 commit comments

Comments
 (0)