当前位置: 首页>>代码示例>>PHP>>正文


PHP BinaryFileResponse::trustXSendfileTypeHeader方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\BinaryFileResponse::trustXSendfileTypeHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP BinaryFileResponse::trustXSendfileTypeHeader方法的具体用法?PHP BinaryFileResponse::trustXSendfileTypeHeader怎么用?PHP BinaryFileResponse::trustXSendfileTypeHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpFoundation\BinaryFileResponse的用法示例。


在下文中一共展示了BinaryFileResponse::trustXSendfileTypeHeader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFileDownloadResponse

 /**
  * @param AttachmentDto $attachmentDto
  * @return BinaryFileResponse
  */
 protected function getFileDownloadResponse(AttachmentDto $attachmentDto)
 {
     $response = new BinaryFileResponse($attachmentDto->getFilePath());
     $response->trustXSendfileTypeHeader();
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $attachmentDto->getFileName(), iconv('UTF-8', 'ASCII//TRANSLIT', $attachmentDto->getFileName()));
     return $response;
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:11,代码来源:ResponseHandlerTrait.php

示例2: invoiceAction

 public function invoiceAction(Convention $convention, Request $request)
 {
     $registrations = $convention->getRegistrations();
     $zip = new ZipArchive();
     $title = $convention->getSlug();
     $filename = tempnam('/tmp/', 'ritsiGA-' . $title . '-');
     unlink($filename);
     if ($zip->open($filename, ZIPARCHIVE::CREATE) !== true) {
         throw new \Exception("cannot open <{$filename}>\n");
     }
     if (false === $zip->addEmptyDir($title)) {
         throw new \Exception("cannot add empty dir {$title}\n");
     }
     $route_dir = $this->container->getParameter('kernel.root_dir');
     foreach ($registrations as $registration) {
         $single_file = $route_dir . '/../private/documents/invoices/' . $registration->getId() . '.pdf';
         if (false === file_exists($single_file)) {
             continue;
         }
         $name = $registration->getId();
         if (false === $zip->addFile($single_file, implode('/', array($title, $name . '.pdf')))) {
             throw new \Exception("cannot add file\n");
         }
     }
     if (false === $zip->close()) {
         throw new \Exception("cannot close <{$filename}>\n");
     }
     $response = new BinaryFileResponse($filename);
     $response->trustXSendfileTypeHeader();
     $response->prepare($request);
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $convention->getSlug() . '-facturas.zip', iconv('UTF-8', 'ASCII//TRANSLIT', $convention->getSlug() . '-facturas.zip'));
     return $response;
 }
开发者ID:aulasoftwarelibre,项目名称:ritsiga,代码行数:33,代码来源:ConventionCRUDController.php

示例3: videoServing

 /**
  * @Route("/video", name="video")
  *
  * Serving video allowing to handle Range and If-Range headers from the request.
  */
 public function videoServing(Request $request)
 {
     $file = $this->getParameter('assetic.write_to') . $this->container->get('templating.helper.assets')->getUrl('video/CreateSafe.mp4');
     $response = new BinaryFileResponse($file);
     BinaryFileResponse::trustXSendfileTypeHeader();
     $response->prepare($request);
     return $response;
 }
开发者ID:DanieleMenara,项目名称:CreateSafe,代码行数:13,代码来源:DefaultController.php

示例4: RenderAction

 public function RenderAction(\SW\DocManagerBundle\Entity\Document $document)
 {
     $path = $document->getPath();
     $response = new BinaryFileResponse($path);
     $response->trustXSendfileTypeHeader();
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $document->getName());
     return $response;
 }
开发者ID:adrienManikon,项目名称:docmanager,代码行数:8,代码来源:ViewController.php

示例5: applyHeaders

 public function applyHeaders(GetResponseEvent $event)
 {
     if (!$this->app['configuration.store']->isSetup()) {
         return;
     }
     if ($this->app['phraseanet.xsendfile-factory']->isXSendFileModeEnabled()) {
         BinaryFileResponse::trustXSendfileTypeHeader();
         $this->app['phraseanet.xsendfile-factory']->getMode()->setHeaders($event->getRequest());
     }
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:10,代码来源:XSendFileSubscriber.php

示例6: testXSendfile

 public function testXSendfile()
 {
     $request = Request::create('/');
     $request->headers->set('X-Sendfile-Type', 'X-Sendfile');
     BinaryFileResponse::trustXSendfileTypeHeader();
     $response = BinaryFileResponse::create('README.md');
     $response->prepare($request);
     $this->expectOutputString('');
     $response->sendContent();
     $this->assertContains('README.md', $response->headers->get('X-Sendfile'));
 }
开发者ID:ragtek,项目名称:symfony,代码行数:11,代码来源:BinaryFileResponseTest.php

示例7: downloadAction

 /**
  * @Route("/{id}/download", name="article_review_download")
  * Función para descargar los artículos
  */
 public function downloadAction(ArticleReview $articleReview)
 {
     $this->denyAccessUnlessGranted('DOWNLOAD', $articleReview);
     $article = $articleReview->getArticle();
     $fileToDownload = $articleReview->getPath();
     $filename = $this->get('slugify')->slugify($article->getTitle()) . '.' . pathinfo($fileToDownload, PATHINFO_EXTENSION);
     $response = new BinaryFileResponse($fileToDownload);
     $response->trustXSendfileTypeHeader();
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $filename, iconv('UTF-8', 'ASCII//TRANSLIT', $filename));
     return $response;
 }
开发者ID:aulasoftwarelibre,项目名称:fastconfer,代码行数:15,代码来源:ArticleReviewController.php

示例8: downloadAction

 public function downloadAction()
 {
     $id = $this->request->query->get('id');
     /** @var Test $entity */
     $entity = $this->em->getRepository('AppBundle:Test')->find($id);
     $filename = sprintf("%s-%s-%s.%s", Slugger::slugify($entity->getSubject()->getName()), Slugger::slugify($entity->getSeason()), Slugger::slugify($entity->getYear()), pathinfo($entity->getFilename(), PATHINFO_EXTENSION));
     $fileToDownload = $this->get('vich_uploader.storage')->resolvePath($entity, 'file');
     $response = new BinaryFileResponse($fileToDownload);
     $response->trustXSendfileTypeHeader();
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename, iconv('UTF-8', 'ASCII//TRANSLIT', $filename));
     return $response;
 }
开发者ID:aulasoftwarelibre,项目名称:biblioteca-examenes,代码行数:12,代码来源:AdminController.php

示例9: afficherDocumentAction

 public function afficherDocumentAction($id)
 {
     $item = $this->getDoctrine()->getRepository('GenericBundle:Formation')->find($id);
     if (!$item) {
         throw $this->createNotFoundException("File with ID {$id} does not exist!");
     }
     $pdfFile = $item->getDocument();
     //returns pdf file stored as mysql blob
     $response = new BinaryFileResponse($pdfFile);
     $response->trustXSendfileTypeHeader();
     $response->headers->set('Content-Type', 'application/pdf');
     return $response;
 }
开发者ID:cgauthier71,项目名称:hub3e,代码行数:13,代码来源:FormationController.php

示例10: vidAction

 /**
  * Serve the file using BinaryFileResponse.
  * 
  * @param string $date
  */
 public function vidAction($date)
 {
     $imageManager = $this->get('theapi_cctv.image_manager');
     try {
         $filename = $imageManager->getVideoFile($date);
         $response = new BinaryFileResponse($filename);
         $response->trustXSendfileTypeHeader();
         $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $filename, iconv('UTF-8', 'ASCII//TRANSLIT', $filename));
     } catch (\Exception $e) {
         throw $this->createNotFoundException($e->getMessage());
     }
     return $response;
 }
开发者ID:theapi,项目名称:cctvbundle,代码行数:18,代码来源:DefaultController.php

示例11: downloadAction

 /**
  * Force download of the specified filename
  *
  * @Route("/download/{filename}", requirements={"filename": ".+"})
  *
  * @param $filename
  * @return BinaryFileResponse
  * @throws NotFoundException
  */
 public function downloadAction($filename)
 {
     $filePath = sprintf('%s/../web/media/%s', $this->get('kernel')->getRootDir(), $filename);
     // Check if requested file exists.
     $fs = new Filesystem();
     if (!$fs->exists($filePath)) {
         throw $this->createNotFoundException();
     }
     // Prepare BinaryFileResponse
     $response = new BinaryFileResponse($filePath);
     $response->trustXSendfileTypeHeader();
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT);
     return $response;
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:23,代码来源:TenancyAgreementController.php

示例12: testDeliverFileWithFilenameAndDispositionAndXSendFileButFileNotInXAccelMapping

 public function testDeliverFileWithFilenameAndDispositionAndXSendFileButFileNotInXAccelMapping()
 {
     BinaryFileResponse::trustXSendfileTypeHeader();
     $this->factory = new ServeFileResponseFactory(new \unicode());
     $mode = new NginxMode([['directory' => __DIR__ . '/../../../../files/', 'mount-point' => '/protected/']]);
     $request = Request::create('/');
     $mode->setHeaders($request);
     $file = __DIR__ . '/../../../../classes/PhraseanetTestCase.php';
     $response = $this->factory->deliverFile($file, 'PhraseanetTestCase.php', 'attachment');
     $response->prepare($request);
     $this->assertInstanceOf("Symfony\\Component\\HttpFoundation\\Response", $response);
     $this->assertEquals('attachment; filename="PhraseanetTestCase.php"', $response->headers->get('content-disposition'));
     $this->assertEquals(realpath($file), $response->headers->get('x-accel-redirect'));
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:14,代码来源:ServeFileResponseFactoryTest.php

示例13: getTestDownloadAction

 /**
  * @ApiDoc(
  *  resource=true,
  *  description="Download a file test",
  *  https=true,
  *  requirements={
  *      {"name": "id", "dataType"="integer", "requirement"="\d+", "description"="Test id"},
  *  }
  * )
  * @Route("/tests/{id}/download")
  * @ParamConverter("test", class="AppBundle:Test", options={"mapping": {"id": "id"}})
  * @QueryParam(name="show", requirements="[01]", default="0", description="0: The file is downloaded, 1: The file is opened on the browser.")
  */
 public function getTestDownloadAction(Test $test, ParamFetcher $paramFetcher)
 {
     $filename = sprintf("%s-%s-%s.%s", Slugger::slugify($test->getSubject()->getName()), Slugger::slugify($test->getSeason()), Slugger::slugify($test->getYear()), pathinfo($test->getFilename(), PATHINFO_EXTENSION));
     $responseType = ResponseHeaderBag::DISPOSITION_ATTACHMENT;
     if ($page = $paramFetcher->get('show') === "1") {
         $responseType = ResponseHeaderBag::DISPOSITION_INLINE;
     }
     $fileToDownload = $this->get('vich_uploader.storage')->resolvePath($test, 'file');
     $response = new BinaryFileResponse($fileToDownload);
     $response->trustXSendfileTypeHeader();
     $response->setContentDisposition($responseType, $filename, iconv('UTF-8', 'ASCII//TRANSLIT', $filename));
     $em = $this->getDoctrine()->getManager();
     $test->incrementDownloads();
     $em->persist($test);
     $em->flush();
     return $response;
 }
开发者ID:aulasoftwarelibre,项目名称:biblioteca-examenes,代码行数:30,代码来源:TestRestController.php

示例14: downloadFileAction

 /**
  * Serve a file by forcing the download
  *
  * @Route("/download/{filename}", name="download_file", requirements={"filename": ".+"})
  */
 public function downloadFileAction($filename)
 {
     /**
      * $basePath can be either exposed (typically inside web/)
      * or "internal"
      */
     $basePath = $this->container->getParameter('kernel.root_dir') . '/Resources/uploads';
     $filePath = $basePath . '/' . $filename;
     // check if file exists
     $fs = new FileSystem();
     if (!$fs->exists($filePath)) {
         throw $this->createNotFoundException();
     }
     // prepare BinaryFileResponse
     $response = new BinaryFileResponse($filePath);
     $response->trustXSendfileTypeHeader();
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $filename, iconv('UTF-8', 'ASCII//TRANSLIT', $filename));
     return $response;
 }
开发者ID:Immolare,项目名称:Litige,代码行数:24,代码来源:MediasController.php

示例15: downloadExistingFile

 public function downloadExistingFile($filename, $fileFullPath)
 {
     $sessionData = new Session();
     $fs = new Filesystem();
     $file = $fileFullPath . $filename;
     if ($fs->exists($file . '.docx')) {
         $fullPath = $file . '.docx';
     } elseif ($fs->exists($file . '.doc')) {
         $fullPath = $file . '.doc';
     } elseif ($fs->exists($file . '.pdf')) {
         $fullPath = $file . '.pdf';
     } else {
         $sessionData->getFlashBag()->add('alert_danger', 'File not found!');
         return false;
     }
     $response = new BinaryFileResponse($fullPath);
     $response->trustXSendfileTypeHeader();
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $filename, iconv('UTF-8', 'ASCII//TRANSLIT', $filename));
     return $response;
 }
开发者ID:souravmondal-cn,项目名称:interviewSystem,代码行数:20,代码来源:FileHandler.php


注:本文中的Symfony\Component\HttpFoundation\BinaryFileResponse::trustXSendfileTypeHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。