當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。