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


PHP FilesystemInterface::readStream方法代码示例

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


在下文中一共展示了FilesystemInterface::readStream方法的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: getResource

 public function getResource($spiBinaryFileId)
 {
     try {
         return $this->filesystem->readStream($spiBinaryFileId);
     } catch (FlysystemNotFoundException $e) {
         throw new BinaryFileNotFoundException($spiBinaryFileId, $e);
     }
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:8,代码来源:Flysystem.php

示例3: setContent

 /**
  * Set the stream response content.
  * @param  StreamedResponse $response The response object.
  * @return StreamedResponse
  */
 public function setContent(StreamedResponse $response)
 {
     $stream = $this->cache->readStream($this->path);
     $response->setCallback(function () use($stream) {
         rewind($stream);
         fpassthru($stream);
         fclose($stream);
     });
     return $response;
 }
开发者ID:awebc,项目名称:web_xbf,代码行数:15,代码来源:ResponseFactory.php

示例4: getFileHash

 public function getFileHash($path)
 {
     $stream = $this->filesystem->readStream($path);
     if ($stream !== false) {
         $context = hash_init(self::HASH_ALGORITHM);
         hash_update_stream($context, $stream);
         return hash_final($context);
     }
     return false;
 }
开发者ID:kivagant,项目名称:staticus-core,代码行数:10,代码来源:DestroyEqualResourceCommand.php

示例5: FileTransferException

 function it_throws_an_exception_when_the_file_can_not_be_read_on_the_filesystem(FileInterface $file, FilesystemInterface $filesystem)
 {
     $file->getKey()->willReturn('path/to/file.txt');
     $filesystem->has('path/to/file.txt')->willReturn(true);
     $filesystem->readStream('path/to/file.txt')->willReturn(false);
     $this->shouldThrow(new FileTransferException('Unable to fetch the file "path/to/file.txt" from the filesystem.'))->during('fetch', [$file, $filesystem]);
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:7,代码来源:RawFileFetcherSpec.php

示例6: open

 /**
  * @return resource|false
  */
 public function open()
 {
     $file = $this->getConfig(self::FILE_LOC);
     if ($this->fileSystem) {
         list($stream) = $this->fileSystem->readStream($file);
         return $stream;
     }
     return fopen($file, 'r+');
 }
开发者ID:wscore,项目名称:site,代码行数:12,代码来源:FlyUpload.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: getGDHandle

 /**
  * @return resource
  */
 public function getGDHandle()
 {
     if (!$this->is_image) {
         return null;
     }
     $size = $this->_filesystem->getSize($this->getPath());
     $handle = $this->_filesystem->readStream($this->getPath());
     return imagecreatefromstring(fread($handle, $size));
 }
开发者ID:stevenimle,项目名称:GMA,代码行数:12,代码来源:File.php

示例9: 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

示例10: 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

示例11: fetch

 /**
  * {@inheritdoc}
  */
 public function fetch(FileInterface $file, FilesystemInterface $filesystem)
 {
     if (!$filesystem->has($file->getKey())) {
         throw new \LogicException(sprintf('The file "%s" is not present on the filesystem.', $file->getKey()));
     }
     $localPathname = tempnam(sys_get_temp_dir(), 'raw_file_fetcher_');
     if (false === ($stream = $filesystem->readStream($file->getKey()))) {
         throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $file->getKey()));
     }
     if (false === file_put_contents($localPathname, $stream)) {
         throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $file->getKey()));
     }
     return new \SplFileInfo($localPathname);
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:17,代码来源:RawFileFetcher.php

示例12: 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

示例13: sendContent

 /**
  * Sends the file.
  */
 public function sendContent()
 {
     if (!$this->isSuccessful()) {
         parent::sendContent();
         return;
     }
     if (0 === $this->maxlen) {
         return;
     }
     $out = fopen('php://output', 'wb');
     $file = $this->filesystem->readStream($this->file->getPath());
     stream_copy_to_stream($file, $out, $this->maxlen, $this->offset);
     fclose($out);
     fclose($file);
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:18,代码来源:FlysystemFileResponse.php

示例14: fetch

 /**
  * {@inheritdoc}
  */
 public function fetch(FilesystemInterface $filesystem, $fileKey)
 {
     if (!$filesystem->has($fileKey)) {
         throw new \LogicException(sprintf('The file "%s" is not present on the filesystem.', $fileKey));
     }
     if (false === ($stream = $filesystem->readStream($fileKey))) {
         throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $fileKey));
     }
     if (!$this->tmpFilesystem->has(dirname($fileKey))) {
         $this->tmpFilesystem->createDir(dirname($fileKey));
     }
     $localPathname = $this->tmpFilesystem->getAdapter()->getPathPrefix() . $fileKey;
     if (false === file_put_contents($localPathname, $stream)) {
         throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $fileKey));
     }
     return new \SplFileInfo($localPathname);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:20,代码来源:FileFetcher.php

示例15: fetch

 /**
  * {@inheritdoc}
  */
 public function fetch(FilesystemInterface $filesystem, $fileKey, array $options = [])
 {
     if (!$filesystem->has($fileKey)) {
         throw new \LogicException(sprintf('The file "%s" is not present on the filesystem.', $fileKey));
     }
     if (false === ($stream = $filesystem->readStream($fileKey))) {
         throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $fileKey));
     }
     if (!$this->tmpFilesystem->has(dirname($fileKey))) {
         $this->tmpFilesystem->createDir(dirname($fileKey));
     }
     // TODO: we should not get the path prefix like that
     // TODO: it should be injected in the constructor
     $localPathname = $this->tmpFilesystem->getAdapter()->getPathPrefix() . $fileKey;
     if (false === file_put_contents($localPathname, $stream)) {
         throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $fileKey));
     }
     return new \SplFileInfo($localPathname);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:22,代码来源:FileFetcher.php


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