當前位置: 首頁>>代碼示例>>PHP>>正文


PHP BinaryFileResponse::sendContent方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpFoundation\BinaryFileResponse::sendContent方法的典型用法代碼示例。如果您正苦於以下問題:PHP BinaryFileResponse::sendContent方法的具體用法?PHP BinaryFileResponse::sendContent怎麽用?PHP BinaryFileResponse::sendContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpFoundation\BinaryFileResponse的用法示例。


在下文中一共展示了BinaryFileResponse::sendContent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sendContent

 /**
  * Sends the file using the encryption manager with the php://output internal stream
  */
 public function sendContent()
 {
     if (!$this->isSuccessful()) {
         parent::sendContent();
         return;
     }
     $this->encryptionManager->decryptFile($this->file->getPathname(), 'php://output', $this->fileSize);
 }
開發者ID:VincentChalnot,項目名稱:SidusEncryptionBundle,代碼行數:11,代碼來源:DecryptFileResponse.php

示例2: index

 /**
  * Download file.
  *
  * @param Request $request
  * @param Response $response
  *
  * @return BinaryFileResponse
  */
 public function index(Request $request, Response $response)
 {
     $key = $request->query->get('key', 'gp');
     $download = $request->query->get('download', '1');
     if ($download == '1') {
         $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT;
     } else {
         $disposition = ResponseHeaderBag::DISPOSITION_INLINE;
     }
     $metaFile = new \Molengo\MetaFile($response);
     $info = $metaFile->getInfo($key);
     $dataFile = $metaFile->getDataFileName($key);
     $fileName = $info['filename'];
     $headers = ['Pragma' => 'public', 'Content-Description' => 'File Transfer', 'Content-Transfer-Encoding' => 'binary', 'Expires' => '0', 'Cache-Control' => 'must-revalidate, post-check = 0, pre-check = 0'];
     $fileResponse = new BinaryFileResponse($dataFile, 200, $headers);
     $fileResponse->deleteFileAfterSend(false);
     $fileResponse->setContentDisposition($disposition, $fileName);
     $fileResponse->prepare($this->request);
     $fileResponse->sendContent();
     // Delete meta file after download
     $metaFile->delete($key);
     return $fileResponse;
 }
開發者ID:odan,項目名稱:molengo-webapp,代碼行數:31,代碼來源:FileController.php

示例3: testDeleteFileAfterSend

 public function testDeleteFileAfterSend()
 {
     $request = Request::create('/');
     $path = __DIR__ . '/File/Fixtures/to_delete';
     touch($path);
     $realPath = realpath($path);
     $this->assertFileExists($realPath);
     $response = new BinaryFileResponse($realPath);
     $response->deleteFileAfterSend(true);
     $response->prepare($request);
     $response->sendContent();
     $this->assertFileNotExists($path);
 }
開發者ID:alexbogo,項目名稱:symfony,代碼行數:13,代碼來源:BinaryFileResponseTest.php

示例4: sendContent

 public function sendContent()
 {
     echo $this->prepend;
     parent::sendContent();
     echo $this->append;
 }
開發者ID:gitiki,項目名稱:code-highlight,代碼行數:6,代碼來源:HighlightLanguageResponse.php


注:本文中的Symfony\Component\HttpFoundation\BinaryFileResponse::sendContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。