Exemplo n.º 1
0
 /**
  * @param File $file
  *
  * @Route("/download/{id}", name="tg_file_download")
  * @return Response
  */
 public function downloadAction(File $file)
 {
     $fs = $this->container->get('oneup_flysystem.mount_manager')->getFilesystem('media_fs');
     $name = $file->getName();
     return new Response($fs->read($name), 200, ['Cache-Control', 'private', 'Content-Type' => $fs->getMimetype($name), 'Content-Disposition' => 'attachment; filename="' . $file->getOriginalName() . '";', 'Content-length' => $fs->getSize($name)]);
 }
Exemplo n.º 2
0
 /**
  * @param File $file
  *
  * @return mixed
  */
 private function getExtension(File $file)
 {
     return strtolower(pathinfo($file->getName(), PATHINFO_EXTENSION));
 }