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


PHP FilesystemInterface::getMimetype方法代码示例

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


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

示例1: create

 /**
  * Create the response.
  *
  * @param \League\Flysystem\FilesystemInterface $cache The cache file system.
  * @param string $path The cached file path.
  *
  * @return \Cake\Network\Response The response object.
  */
 public function create(FilesystemInterface $cache, $path)
 {
     $stream = $cache->readStream($path);
     $contentType = $cache->getMimetype($path);
     $contentLength = (string) $cache->getSize($path);
     $response = new Response();
     $response->type($contentType);
     $response->header('Content-Length', $contentLength);
     $response->body(function () use($stream) {
         rewind($stream);
         fpassthru($stream);
         fclose($stream);
     });
     return $response;
 }
开发者ID:josegonzalez,项目名称:cakephp-glide,代码行数:23,代码来源:CakeResponseFactory.php

示例2: find

 /**
  * {@inheritdoc}
  */
 public function find($path)
 {
     if ($this->filesystem->has($path) === false) {
         throw new NotLoadableException(sprintf('Source image "%s" not found.', $path));
     }
     $mimeType = $this->filesystem->getMimetype($path);
     return new Binary($this->filesystem->read($path), $mimeType, $this->extensionGuesser->guess($mimeType));
 }
开发者ID:graundas,项目名称:LiipImagineBundle,代码行数:11,代码来源:FlysystemLoader.php

示例3: setHeaders

 /**
  * Set the streamed response headers.
  * @param  StreamedResponse $response The response object.
  * @return StreamedResponse
  */
 public function setHeaders(StreamedResponse $response)
 {
     $response->headers->set('Content-Type', $this->cache->getMimetype($this->path));
     $response->headers->set('Content-Length', $this->cache->getSize($this->path));
     $response->setPublic();
     $response->setMaxAge(31536000);
     $response->setExpires(date_create()->modify('+1 years'));
     $response->setLastModified(date_create()->setTimestamp($this->cache->getTimestamp($this->path)));
     $response->isNotModified($this->request);
     return $response;
 }
开发者ID:awebc,项目名称:web_xbf,代码行数:16,代码来源:ResponseFactory.php

示例4: _stat

 /**
  * Return stat for given path.
  * Stat contains following fields:
  * - (int)    size    file size in b. required
  * - (int)    ts      file modification time in unix time. required
  * - (string) mime    mimetype. required for folders, others - optionally
  * - (bool)   read    read permissions. required
  * - (bool)   write   write permissions. required
  * - (bool)   locked  is object locked. optionally
  * - (bool)   hidden  is object hidden. optionally
  * - (string) alias   for symlinks - link target path relative to root path. optionally
  * - (string) target  for symlinks - link target path. optionally
  *
  * If file does not exists - returns empty array or false.
  *
  * @param  string  $path    file path
  * @return array|false
  **/
 protected function _stat($path)
 {
     $stat = array('mime' => 'directory', 'ts' => time(), 'read' => true, 'write' => true, 'locked' => false, 'hidden' => false, 'size' => 0);
     // If root, just return from above
     if ($this->root == $path) {
         $stat['name'] = $this->root;
         return $stat;
     }
     // If not exists, return empty
     if (!$this->fs->has($path)) {
         return array();
     }
     $meta = $this->fs->getMetadata($path);
     // Get timestamp/size
     $stat['ts'] = isset($meta['timestamp']) ? $meta['timestamp'] : $this->fs->getTimestamp($path);
     $stat['size'] = isset($meta['size']) ? $meta['size'] : $this->fs->getSize($path);
     // Check if file, if so, check mimetype
     if ($meta['type'] == 'file') {
         $stat['mime'] = isset($meta['mimetype']) ? $meta['mimetype'] : $this->fs->getMimetype($path);
         $imgMimes = ['image/jpeg', 'image/png', 'image/gif'];
         if ($this->urlBuilder && in_array($stat['mime'], $imgMimes)) {
             $stat['url'] = $this->urlBuilder->getUrl($path, ['ts' => $stat['ts']]);
             $stat['tmb'] = $this->urlBuilder->getUrl($path, ['ts' => $stat['ts'], 'w' => $this->tmbSize, 'h' => $this->tmbSize, 'fit' => $this->options['tmbCrop'] ? 'crop' : 'contain']);
         }
     }
     if (!isset($stat['url']) && $this->fs->getUrl()) {
         $stat['url'] = 1;
     }
     return $stat;
 }
开发者ID:quepasso,项目名称:dashboard,代码行数:48,代码来源:ElFinderVolumeFlysystem.php

示例5: _stat

 /**
  * Return stat for given path.
  * Stat contains following fields:
  * - (int)    size    file size in b. required
  * - (int)    ts      file modification time in unix time. required
  * - (string) mime    mimetype. required for folders, others - optionally
  * - (bool)   read    read permissions. required
  * - (bool)   write   write permissions. required
  * - (bool)   locked  is object locked. optionally
  * - (bool)   hidden  is object hidden. optionally
  * - (string) alias   for symlinks - link target path relative to root path. optionally
  * - (string) target  for symlinks - link target path. optionally
  *
  * If file does not exists - returns empty array or false.
  *
  * @param  string $path file path
  * @return array|false
  **/
 protected function _stat($path)
 {
     $stat = array('size' => 0, 'ts' => time(), 'read' => true, 'write' => true, 'locked' => false, 'hidden' => false, 'mime' => 'directory');
     // If root, just return from above
     if ($this->root == $path) {
         $stat['name'] = $this->root;
         return $stat;
     }
     // If not exists, return empty
     if (!$this->fs->has($path)) {
         // Check if the parent doesn't have this path
         if ($this->_dirExists($path)) {
             return $stat;
         }
         // Neither a file or directory exist, return empty
         return array();
     }
     try {
         $meta = $this->fs->getMetadata($path);
     } catch (\Exception $e) {
         return array();
     }
     if (false === $meta) {
         return $stat;
     }
     // Set item filename.extension to `name` if exists
     if (isset($meta['filename']) && isset($meta['extension'])) {
         $stat['name'] = $meta['filename'];
         if ($meta['extension'] !== '') {
             $stat['name'] .= '.' . $meta['extension'];
         }
     }
     // Get timestamp/size if available
     if (isset($meta['timestamp'])) {
         $stat['ts'] = $meta['timestamp'];
     }
     if (isset($meta['size'])) {
         $stat['size'] = $meta['size'];
     }
     // Check if file, if so, check mimetype when available
     if ($meta['type'] == 'file') {
         if (isset($meta['mimetype'])) {
             $stat['mime'] = $meta['mimetype'];
         } else {
             $stat['mime'] = $this->fs->getMimetype($path);
         }
         $imgMimes = ['image/jpeg', 'image/png', 'image/gif'];
         if ($this->urlBuilder && in_array($stat['mime'], $imgMimes)) {
             $stat['url'] = $this->urlBuilder->getUrl($path, ['ts' => $stat['ts']]);
             $stat['tmb'] = $this->urlBuilder->getUrl($path, ['ts' => $stat['ts'], 'w' => $this->tmbSize, 'h' => $this->tmbSize, 'fit' => $this->options['tmbCrop'] ? 'crop' : 'contain']);
         }
     }
     if (!isset($stat['url']) && $this->fs->getUrl()) {
         $stat['url'] = 1;
     }
     return $stat;
 }
开发者ID:barryvdh,项目名称:elfinder-flysystem-driver,代码行数:75,代码来源:Driver.php

示例6: getMimetype

 /**
  * @override
  * @inheritDoc
  */
 public function getMimetype($path)
 {
     try {
         return $this->fs->getMimetype($path);
     } catch (Error $ex) {
     } catch (Exception $ex) {
     }
     throw new ReadException("File {$path} mimetype could not be determined.", $ex);
 }
开发者ID:kraken-php,项目名称:framework,代码行数:13,代码来源:Filesystem.php

示例7: create

 /**
  * Create response.
  * @param  FilesystemInterface $cache Cache file system.
  * @param  string              $path  Cached file path.
  * @return Response            Response object.
  */
 public function create(FilesystemInterface $cache, $path)
 {
     $stream = $this->streamCallback->__invoke($cache->readStream($path));
     $contentType = $cache->getMimetype($path);
     $contentLength = (string) $cache->getSize($path);
     $cacheControl = 'max-age=31536000, public';
     $expires = date_create('+1 years')->format('D, d M Y H:i:s') . ' GMT';
     return $this->response->withBody($stream)->withHeader('Content-Type', $contentType)->withHeader('Content-Length', $contentLength)->withHeader('Cache-Control', $cacheControl)->withHeader('Expires', $expires);
 }
开发者ID:whismat,项目名称:glide,代码行数:15,代码来源:PsrResponseFactory.php

示例8: outputImage

 /**
  * Generate and output image.
  * @param  string                   $path   Image path.
  * @param  array                    $params Image manipulation params.
  * @throws InvalidArgumentException
  */
 public function outputImage($path, array $params)
 {
     $path = $this->makeImage($path, $params);
     header('Content-Type:' . $this->cache->getMimetype($path));
     header('Content-Length:' . $this->cache->getSize($path));
     header('Cache-Control:' . 'max-age=31536000, public');
     header('Expires:' . date_create('+1 years')->format('D, d M Y H:i:s') . ' GMT');
     $stream = $this->cache->readStream($path);
     rewind($stream);
     fpassthru($stream);
     fclose($stream);
 }
开发者ID:mambax7,项目名称:glide,代码行数:18,代码来源:Server.php

示例9: create

 /**
  * Create response.
  *
  * @param \League\Flysystem\FilesystemInterface $cache Cache file system.
  * @param string $path Cached file path.
  *
  * @return \Psr\Http\Message\ResponseInterface Response object.
  */
 public function create(FilesystemInterface $cache, $path)
 {
     $stream = new Stream($cache->readStream($path));
     $contentType = $cache->getMimetype($path);
     $contentLength = (string) $cache->getSize($path);
     if ($contentType === false) {
         throw new FilesystemException('Unable to determine the image content type.');
     }
     if ($contentLength === false) {
         throw new FilesystemException('Unable to determine the image content length.');
     }
     return (new Response())->withBody($stream)->withHeader('Content-Type', $contentType)->withHeader('Content-Length', $contentLength);
 }
开发者ID:admad,项目名称:cakephp-glide,代码行数:21,代码来源:PsrResponseFactory.php

示例10: create

 /**
  * Create response.
  * @param  FilesystemInterface $cache Cache file system.
  * @param  string              $path  Cached file path.
  * @return ResponseInterface   Response object.
  */
 public function create(FilesystemInterface $cache, $path)
 {
     $stream = $this->streamCallback->__invoke($cache->readStream($path));
     $contentType = $cache->getMimetype($path);
     $contentLength = (string) $cache->getSize($path);
     $cacheControl = 'max-age=31536000, public';
     $expires = date_create('+1 years')->format('D, d M Y H:i:s') . ' GMT';
     if ($contentType === false) {
         throw new FilesystemException('Unable to determine the image content type.');
     }
     if ($contentLength === false) {
         throw new FilesystemException('Unable to determine the image content length.');
     }
     return $this->response->withBody($stream)->withHeader('Content-Type', $contentType)->withHeader('Content-Length', $contentLength)->withHeader('Cache-Control', $cacheControl)->withHeader('Expires', $expires);
 }
开发者ID:mambax7,项目名称:glide,代码行数:21,代码来源:PsrResponseFactory.php

示例11: uploadFile

 protected function uploadFile(UploadedFileInterface $content, $mime, $filePath)
 {
     $uri = $content->getStream()->getMetadata('uri');
     if (!$uri) {
         throw new SaveResourceErrorException('Unknown error: can\'t get uploaded file uri');
     }
     $uploadedMime = $this->filesystem->getMimetype($uri);
     if ($mime !== $uploadedMime) {
         /**
          * Try to remove unnecessary file because UploadFile object can be emulated
          * @see \Staticus\Middlewares\ActionPostAbstract::download
          */
         $this->filesystem->delete($uri);
         throw new WrongRequestException('Bad request: incorrect mime-type of the uploaded file');
     }
     $content->moveTo($filePath);
 }
开发者ID:kivagant,项目名称:staticus-core,代码行数:17,代码来源:SaveResourceMiddlewareAbstract.php

示例12: createResponseFor

 /**
  * Generate an {@see SS_HTTPResponse} for the given file from the source filesystem
  * @param FilesystemInterface $flysystem
  * @param string $fileID
  * @return SS_HTTPResponse
  */
 protected function createResponseFor(FilesystemInterface $flysystem, $fileID)
 {
     // Build response body
     // @todo: gzip / buffer response?
     $body = $flysystem->read($fileID);
     $mime = $flysystem->getMimetype($fileID);
     $response = new SS_HTTPResponse($body, 200);
     // Add headers
     $response->addHeader('Content-Type', $mime);
     $headers = Config::inst()->get(get_class($this), 'file_response_headers');
     foreach ($headers as $header => $value) {
         $response->addHeader($header, $value);
     }
     return $response;
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:21,代码来源:FlysystemAssetStore.php

示例13: getMimetype

 /**
  * Get the file's mimetype.
  * 
  * @return string
  */
 public function getMimetype()
 {
     return $this->filesystem->getMimetype($this->path);
 }
开发者ID:bfrager,项目名称:evernote-ocr,代码行数:9,代码来源:FlysystemFileAdapter.php

示例14: getMimetype

 /**
  * Get a file's mime-type.
  *
  * @param string $path The path to the file.
  *
  * @throws FileNotFoundException
  *
  * @return string|false The file mime-type or false on failure.
  */
 public function getMimetype($path)
 {
     return $this->fileSystem->getMimetype($path);
 }
开发者ID:graze,项目名称:data-file,代码行数:13,代码来源:FilesystemWrapper.php

示例15: getMimeType

 public function getMimeType($spiBinaryFileId)
 {
     return $this->filesystem->getMimetype($spiBinaryFileId);
 }
开发者ID:blankse,项目名称:ezpublish-kernel-1,代码行数:4,代码来源:Flysystem.php


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