I posted an answer on StackOverflow:
See this issue: https://github.com/symfony/symfony/issues/6530 and this line: https://github.com/symfony/symfony/blob/2.4/src/Symfony/Component/HttpFoundation/StreamedResponse.php#L87
It suggests to use BinaryFileResponse instead. Something like this:
$response = new Symfony\Component\HttpFoundation\BinaryFileResponse($file);
$response->setContentDisposition('inline');
$response->setTtl(300);
return $response;
//Or with setting the headers manually
return new Symfony\Component\HttpFoundation\BinaryFileResponse($file, 200, $headers, true, 'inline');
//Or Laravel style:
return Response::download($file)->setTtl(300)->setContentDisposition('inline');
return Response::download($file, null, $headers)->setContentDisposition('inline');
That's perfect, thanks a ton! I wonder what the rationale was behind not checking to see if the Cache-Control was set before hard-coding it? In any event, it would have been nice if that little gotcha were documented somewhere. I swear, I've been Googling this for days and couldn't find a word about having this issue when trying to send binary files. Anyway, thanks again for the solution!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community