public function downloadAction(Request $request, $id)
{
try {
if (ob_get_length()) {
ob_end_clean();
}
$version = $request->get('v', null);
$noCount = $request->get('no-count', false);
$fileVersion = $this->getFileVersion($id, $version);
if (!$fileVersion) {
return new Response(null, 404);
}
$dispositionType = ResponseHeaderBag::DISPOSITION_ATTACHMENT;
if ($request->get('inline', false)) {
$dispositionType = ResponseHeaderBag::DISPOSITION_INLINE;
}
if (!$noCount) {
$this->getMediaManager()->increaseDownloadCounter($fileVersion->getId());
}
$response = $this->getFileResponse($fileVersion, $request->getLocale(), $dispositionType);
return $response;
} catch (MediaException $e) {
throw $this->createNotFoundException('File not found: ' . $e->getCode() . ' ' . $e->getMessage());
}
}