public function downloadAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var $file \Orkestra\Bundle\ApplicationBundle\Entity\File */
        $file = $em->find('Orkestra\Bundle\ApplicationBundle\Entity\File', $id);

        if (!$file) {
            throw $this->createNotFoundException('Unable to locate File');
        }

        $securityContext = $this->get('security.authorization_checker');

        foreach ($file->getGroups() as $group) {
            if (!$securityContext->isGranted($group->getRole())) {
                throw $this->createNotFoundException('Unable to locate File');
            }
        }

        return new Response($file->getContent(), 200, array(
            'Content-Type' => $file->getMimeType(),
            'Content-Disposition' => sprintf('attachment; filename="%s"', $file->getFilename())
        ));
    }