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


PHP BinaryFileResponse::setPrivate方法代码示例

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


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

示例1: deliverFile

 /**
  * {@inheritdoc}
  */
 public function deliverFile($file, $filename = '', $disposition = self::DISPOSITION_INLINE, $mimeType = null, $cacheDuration = 0)
 {
     $response = new BinaryFileResponse($file);
     $response->setContentDisposition($disposition, $this->sanitizeFilename($filename), $this->sanitizeFilenameFallback($filename));
     $response->setMaxAge($cacheDuration);
     $response->setPrivate();
     if (null !== $mimeType) {
         $response->headers->set('Content-Type', $mimeType);
     }
     return $response;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:14,代码来源:ServeFileResponseFactory.php

示例2: handleServeIconRequest

 /**
  * Handle request to /serve-icon handler
  *
  * @param bool $allow_removing_headers Alter PHP's global headers to allow caching
  * @return BinaryFileResponse
  */
 public function handleServeIconRequest($allow_removing_headers = true)
 {
     $response = new Response();
     $response->setExpires($this->getCurrentTime('-1 day'));
     $response->prepare($this->request);
     if ($allow_removing_headers) {
         // clear cache-boosting headers set by PHP session
         header_remove('Cache-Control');
         header_remove('Pragma');
         header_remove('Expires');
     }
     $path = implode('/', $this->request->getUrlSegments());
     if (!preg_match('~serve-icon/(\\d+)/(.*+)$~', $path, $m)) {
         return $response->setStatusCode(400)->setContent('Malformatted request URL');
     }
     list(, $guid, $size) = $m;
     $entity = $this->entities->get($guid);
     if (!$entity instanceof \ElggEntity) {
         return $response->setStatusCode(404)->setContent('Item does not exist');
     }
     $thumbnail = $entity->getIcon($size);
     if (!$thumbnail->exists()) {
         return $response->setStatusCode(404)->setContent('Icon does not exist');
     }
     $if_none_match = $this->request->headers->get('if_none_match');
     if (!empty($if_none_match)) {
         // strip mod_deflate suffixes
         $this->request->headers->set('if_none_match', str_replace('-gzip', '', $if_none_match));
     }
     $filenameonfilestore = $thumbnail->getFilenameOnFilestore();
     $last_updated = filemtime($filenameonfilestore);
     $etag = '"' . $last_updated . '"';
     $response->setPrivate()->setEtag($etag)->setExpires($this->getCurrentTime('+1 day'))->setMaxAge(86400);
     if ($response->isNotModified($this->request)) {
         return $response;
     }
     $headers = ['Content-Type' => (new MimeTypeDetector())->getType($filenameonfilestore)];
     $response = new BinaryFileResponse($filenameonfilestore, 200, $headers, false, 'inline');
     $response->prepare($this->request);
     $response->setPrivate()->setEtag($etag)->setExpires($this->getCurrentTime('+1 day'))->setMaxAge(86400);
     return $response;
 }
开发者ID:elgg,项目名称:elgg,代码行数:48,代码来源:EntityIconService.php


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