@@ -481,17 +481,18 @@ non-ASCII filenames is more involving. The
481481:method: `Symfony\\ Component\\ HttpFoundation\\ ResponseHeaderBag::makeDisposition `
482482abstracts the hard work behind a simple API::
483483
484+ use Symfony\Component\HttpFoundation\Response;
484485 use Symfony\Component\HttpFoundation\ResponseHeaderBag;
485486
486- $d = $response->headers->makeDisposition(
487+ $fileContent = ...; // the generated file content
488+ $response = new Response($fileContent);
489+
490+ $disposition = $response->headers->makeDisposition(
487491 ResponseHeaderBag::DISPOSITION_ATTACHMENT,
488492 'foo.pdf'
489493 );
490494
491- $response->headers->set('Content-Disposition', $d);
492-
493- Then you must set the file's content as usual, for example by using
494- :method: `Symfony\\ Component\\ HttpFoundation\\ Response::setContent `.
495+ $response->headers->set('Content-Disposition', $disposition);
495496
496497Alternatively, if you are serving a static file, you can use a
497498:class: `Symfony\\ Component\\ HttpFoundation\\ BinaryFileResponse `::
@@ -513,6 +514,7 @@ if it should::
513514With the ``BinaryFileResponse ``, you can still set the ``Content-Type `` of the sent file,
514515or change its ``Content-Disposition ``::
515516
517+ // ...
516518 $response->headers->set('Content-Type', 'text/plain');
517519 $response->setContentDisposition(
518520 ResponseHeaderBag::DISPOSITION_ATTACHMENT,
0 commit comments