Leon Willens
Leon Willens

Reputation: 356

Symfony - BinaryFileResponse returns a ResponseHeader, but no file

currently trying to serve a static PDF file that is not within the web directory ($reasons).

I applied

$filepath = $this->getTargetFile($level, $name);

$response = new BinaryFileResponse($filepath);
$response->headers->set('Content-Type', 'application/pdf');
$response->setContentDisposition(
    ResponseHeaderBag::DISPOSITION_INLINE,
    $filename
);
return $response;

and Profiler shows that there is a Response with correct headers, but there is no document view and no download prompt whatsoever. Is there something I am missing?

/** Get target file */
public function getTargetFile($level, $name)
{
    return $this->kernel->locateResource($staticPath . $level . '/' . $name);
}

Upvotes: 0

Views: 1059

Answers (1)

Leon Willens
Leon Willens

Reputation: 356

Some nerves were spent, but:

I created a form via JavaScript and submitted the needed parameters into a new window (thanks to this), that made the job. If anyone has a "cleaner" solution, I'm open to suggestions :)

Upvotes: 1

Related Questions