Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a1aaae3

Browse filesBrowse files
[HttpFoundation] Add doc for File\Stream
1 parent fefc2f2 commit a1aaae3
Copy full SHA for a1aaae3

File tree

1 file changed

+14
-0
lines changed
Filter options

1 file changed

+14
-0
lines changed

‎components/http_foundation.rst

Copy file name to clipboardExpand all lines: components/http_foundation.rst
+14Lines 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+
.. versionaded:: 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.