示例#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)]);
 }