Esempio n. 1
0
 /**
  * @param Attachment                $attachment
  * @param AttachmentHelperInterface $helper
  *
  * @return string
  */
 public function download(Attachment $attachment, AttachmentHelperInterface $helper)
 {
     $file = $helper->getAttachmentLocation($attachment);
     if (file_exists($file)) {
         $quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));
         return response(Crypt::decrypt(file_get_contents($file)), 200)->header('Content-Description', 'File Transfer')->header('Content-Type', 'application/octet-stream')->header('Content-Disposition', 'attachment; filename=' . $quoted)->header('Content-Transfer-Encoding', 'binary')->header('Connection', 'Keep-Alive')->header('Expires', '0')->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')->header('Pragma', 'public')->header('Content-Length', $attachment->size);
     } else {
         abort(404);
     }
 }
 /**
  * @param Attachment                $attachment
  * @param AttachmentHelperInterface $helper
  */
 public function download(Attachment $attachment, AttachmentHelperInterface $helper)
 {
     $file = $helper->getAttachmentLocation($attachment);
     if (file_exists($file)) {
         $quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));
         header('Content-Description: File Transfer');
         header('Content-Type: application/octet-stream');
         header('Content-Disposition: attachment; filename=' . $quoted);
         header('Content-Transfer-Encoding: binary');
         header('Connection: Keep-Alive');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
         header('Content-Length: ' . $attachment->size);
         echo Crypt::decrypt(file_get_contents($file));
     } else {
         abort(404);
     }
 }