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


PHP Util::rewindStream方法代码示例

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


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

示例1: stream

 /**
  * Stream fallback delegator.
  *
  * @param string   $path
  * @param resource $resource
  * @param Config   $config
  * @param string   $fallback
  *
  * @return mixed fallback result
  */
 protected function stream($path, $resource, Config $config, $fallback)
 {
     Util::rewindStream($resource);
     $contents = stream_get_contents($resource);
     $fallbackCall = [$this, $fallback];
     return call_user_func($fallbackCall, $path, $contents, $config);
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:17,代码来源:StreamedWritingTrait.php

示例2: updateStream

 /**
  * {@inheritdoc}
  */
 public function updateStream($path, $resource, array $config = [])
 {
     if (!is_resource($resource)) {
         throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
     }
     $path = Util::normalizePath($path);
     $config = $this->prepareConfig($config);
     $this->assertPresent($path);
     Util::rewindStream($resource);
     return (bool) $this->getAdapter()->updateStream($path, $resource, $config);
 }
开发者ID:RyanThompson,项目名称:flysystem,代码行数:14,代码来源:Filesystem.php

示例3: getStreamAsFile

 /**
  * Get stream as a file
  *
  * @param resource $stream
  * @return string Filename of resulting stream content
  * @throws Exception
  */
 protected function getStreamAsFile($stream)
 {
     // Get temporary file and name
     $file = tempnam(sys_get_temp_dir(), 'ssflysystem');
     $buffer = fopen($file, 'w');
     if (!$buffer) {
         throw new Exception("Could not create temporary file");
     }
     // Transfer from given stream
     Util::rewindStream($stream);
     stream_copy_to_stream($stream, $buffer);
     if (!fclose($buffer)) {
         throw new Exception("Could not write stream to temporary file");
     }
     return $file;
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:23,代码来源:FlysystemAssetStore.php

示例4: updateStream

 /**
  * Update a file with the contents of a stream.
  *
  * @param string   $path
  * @param resource $resource
  * @param mixed    $config   Config object or visibility setting
  *
  * @throws InvalidArgumentException
  *
  * @return bool success boolean
  */
 public function updateStream($path, $resource, array $config = [])
 {
     if (!is_resource($resource)) {
         throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
     }
     $path = Util::normalizePath($path);
     $config = $this->prepareConfig($config);
     $this->assertPresent($path);
     Util::rewindStream($resource);
     if (!($object = $this->adapter->updateStream($path, $resource, $config))) {
         return false;
     }
     $this->cache->updateObject($path, $object + ['contents' => false], true);
     return true;
 }
开发者ID:nguyenducduy,项目名称:phblog,代码行数:26,代码来源:Filesystem.php

示例5: updateStream

 /**
  * Update an existing file using a stream.
  *
  * @param string   $path     The path of the existing file.
  * @param resource $resource The file handle.
  * @param array    $config   An optional configuration array.
  *
  * @throws InvalidArgumentException If $resource is not a file handle.
  * @throws FileNotFoundException
  *
  * @return bool True on success, false on failure.
  */
 public function updateStream($path, $resource, array $config = [])
 {
     $media = $this->find($path, true);
     $realPath = $media->realPath;
     if (!($destination = fopen($realPath . '.new', 'w+'))) {
         return false;
     }
     stream_copy_to_stream($resource, $destination);
     if (!fclose($destination)) {
         return false;
     }
     $oldPath = $realPath . 'old' . time();
     if (!rename($realPath, $oldPath) || !rename($realPath . '.new', $realPath)) {
         return false;
     }
     unlink($oldPath);
     Util::rewindStream($resource);
     return $media !== null;
 }
开发者ID:rabbitcms,项目名称:filemanager,代码行数:31,代码来源:Media.php

示例6: updateStream

 /**
  * Update a file with the contents of a stream
  *
  * @param   string    $path
  * @param   resource  $resource
  * @param   mixed     $config   Config object or visibility setting
  * @return  bool      success boolean
  * @throws  InvalidArgumentException
  */
 public function updateStream($path, $resource, $config = null)
 {
     if (!is_resource($resource)) {
         throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
     }
     $path = Util::normalizePath($path);
     $config = Util::ensureConfig($config);
     $config->setFallback($this->getConfig());
     $this->assertPresent($path);
     Util::rewindStream($resource);
     if (!($object = $this->adapter->updateStream($path, $resource, $config))) {
         return false;
     }
     $this->cache->updateObject($path, $object, true);
     return true;
 }
开发者ID:parabol,项目名称:laravel-cms,代码行数:25,代码来源:Filesystem.php

示例7: putStream

 /**
  * {@inheritdoc}
  */
 public function putStream($path, $resource, $config = [])
 {
     $resource = $this->normalizeResource($resource, __METHOD__);
     $path = $this->normalizePath($path);
     $config = $this->prepareConfig($config);
     Flysystem\Util::rewindStream($resource);
     $this->doPutStream($path, $resource, $config);
 }
开发者ID:pkdevboxy,项目名称:filesystem,代码行数:11,代码来源:Filesystem.php


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