Symfony's BinaryFileResponse allows presenting files to download to HTTP Clients. However, this expects full file paths. Some projects may want to stream a PSR-7 Stream to the client instead.
Instead of returning a BinaryFileResponse, create a PSR7StreamResponse, and return that.
$response = new BinaryFileResponse($filePath);
$response = $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'my-file.mp3');
return $response;
$response = new PSR7StreamResponse($stream, 'audio/mpeg');
$response = $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'my-file.mp3');
return $response;