public function getFileAction($id)
{
/**
* @var EntityManager
*/
$em = $this->getDoctrine()->getManager();
/**
* @var UploadedFile
*/
$file = $em->find($this->getEntityClass(), $id);
$storage = $this->get('partkeepr_uploadedfile_service')->getStorage($file);
try {
return new Response($storage->read($file->getFullFilename()), 200, ['Content-Type' => $file->getMimeType()]);
} catch (FileNotFound $e) {
$this->get('logger')->addError(sprintf('File %s not found in storage %s', $file->getFullFilename(), $file->getType()));
return new Response('404 File not found', 404);
}
}