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


PHP FilesystemInterface::putStream方法代码示例

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


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

示例1: put

 /**
  * Write the contents of a file.
  *
  * @param string          $path
  * @param string|resource $contents
  * @param string          $visibility
  *
  * @return bool
  */
 public function put($path, $contents, $visibility = null)
 {
     $config = ['visibility' => $this->parseVisibility($visibility)];
     if (is_resource($contents)) {
         return $this->driver->putStream($path, $contents, $config);
     }
     return $this->driver->put($path, $contents, $config);
 }
开发者ID:speedwork,项目名称:filesystem,代码行数:17,代码来源:FilesystemAdapter.php

示例2: write

 /**
  * @inheritdoc
  */
 public function write($path, SplFileInfo $file)
 {
     $stream = fopen($file->getRealPath(), 'r+');
     $result = $this->filesystem->putStream($path, $stream);
     if (is_resource($stream)) {
         fclose($stream);
     }
     return $result;
 }
开发者ID:xaben,项目名称:XabenMediaBundle,代码行数:12,代码来源:FlysystemAdapter.php

示例3: writeFile

 /**
  * @param $filePath
  * @param $content
  */
 protected function writeFile($filePath, $content)
 {
     if (is_resource($content)) {
         $result = $this->filesystem->putStream($filePath, $content);
     } else {
         $result = $this->filesystem->put($filePath, $content);
     }
     if (!$result) {
         throw new SaveResourceErrorException('File cannot be written to the path ' . $filePath);
     }
 }
开发者ID:kivagant,项目名称:staticus-core,代码行数:15,代码来源:SaveResourceMiddlewareAbstract.php

示例4: put

 /**
  * Write the contents of a file.
  *
  * @param  string  $path
  * @param  string|resource  $contents
  * @param  array  $options
  * @return bool
  */
 public function put($path, $contents, $options = [])
 {
     if (is_string($options)) {
         $options = ['visibility' => $options];
     }
     if ($contents instanceof File || $contents instanceof UploadedFile) {
         return $this->putFile($path, $contents, $options);
     }
     if (is_resource($contents)) {
         return $this->driver->putStream($path, $contents, $options);
     } else {
         return $this->driver->put($path, $contents, $options);
     }
 }
开发者ID:jarnovanleeuwen,项目名称:framework,代码行数:22,代码来源:FilesystemAdapter.php

示例5: put

 /**
  * Write the contents of a file.
  *
  * @param  string  $path
  * @param  string|resource  $contents
  * @param  string  $visibility
  * @return bool
  */
 public function put($path, $contents, $visibility = null)
 {
     if ($contents instanceof File || $contents instanceof UploadedFile) {
         return $this->putFile($path, $contents, $visibility);
     }
     if ($visibility = $this->parseVisibility($visibility)) {
         $config = ['visibility' => $visibility];
     } else {
         $config = [];
     }
     if (is_resource($contents)) {
         return $this->driver->putStream($path, $contents, $config);
     } else {
         return $this->driver->put($path, $contents, $config);
     }
 }
开发者ID:davidhemphill,项目名称:framework,代码行数:24,代码来源:FilesystemAdapter.php

示例6: push

 /**
  * {@inheritdoc}
  */
 public function push(BackupInterface $backup)
 {
     $backupDirectory = $backup->getName();
     if (!$this->flysystem->has($backupDirectory) && !$this->flysystem->createDir($backupDirectory)) {
         throw new DestinationException(sprintf('Unable to create backup directory "%s" in flysystem destination.', $backupDirectory));
     }
     $removedBackupFiles = $this->getFiles($backupDirectory);
     /**
      * @var FileInterface $backupFile
      */
     foreach ($backup->getFiles() as $backupFile) {
         if (isset($removedBackupFiles[$backupFile->getRelativePath()])) {
             unset($removedBackupFiles[$backupFile->getRelativePath()]);
         }
         $path = $backupDirectory . '/' . $backupFile->getRelativePath();
         try {
             if ($this->flysystem->has($path)) {
                 if ($backupFile->getModifiedAt() > new \DateTime('@' . $this->flysystem->getTimestamp($path))) {
                     $resource = fopen($backupFile->getPath(), 'r');
                     $this->flysystem->updateStream($path, $resource);
                     fclose($resource);
                 }
             } else {
                 $resource = fopen($backupFile->getPath(), 'r');
                 $this->flysystem->putStream($path, $resource);
                 fclose($resource);
             }
         } catch (\Exception $e) {
             throw new DestinationException(sprintf('Unable to backup file "%s" to flysystem destination.', $backupFile->getPath()), 0, $e);
         }
     }
     /**
      * @var FileInterface $removedBackupFile
      */
     foreach ($removedBackupFiles as $removedBackupFile) {
         $path = $backupDirectory . '/' . $removedBackupFile->getRelativePath();
         try {
             $this->flysystem->delete($path);
         } catch (\Exception $e) {
             throw new DestinationException(sprintf('Unable to cleanup backup destination "%s" after backup process, file "%s" could not be removed.', $backupDirectory, $path), 0, $e);
         }
     }
     $this->removeEmptyDirectories($backupDirectory);
     if (is_array($this->backups)) {
         $this->backups[$backup->getName()] = $backup;
     }
 }
开发者ID:runopencode,项目名称:backup,代码行数:50,代码来源:FlysystemDestination.php

示例7: writeStream

 /**
  * @inheritdoc
  */
 public function writeStream($path, $resource, $append = false)
 {
     $path = $this->strategy->encode($path);
     if ($append === false && $this->filesystem->has($path)) {
         $this->filesystem->delete($path);
     }
     $this->filesystem->putStream($path, $resource);
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:11,代码来源:MediaService.php

示例8: _save

 /**
  * Create new file and write into it from file pointer.
  * Return new file path or false on error.
  *
  * @param  resource  $fp   file pointer
  * @param  string    $dir  target dir path
  * @param  string    $name file name
  * @param  array     $stat file stat (required by some virtual fs)
  * @return bool|string
  **/
 protected function _save($fp, $dir, $name, $stat)
 {
     $path = $this->_joinPath($dir, $name);
     if ($this->fs->putStream($path, $fp)) {
         return $path;
     }
     return false;
 }
开发者ID:steve-todorov,项目名称:ElFinderPHP,代码行数:18,代码来源:ElFinderVolumeFlysystem.php

示例9: _save

 /**
  * Create new file and write into it from file pointer.
  * Return new file path or false on error.
  *
  * @param  resource  $fp   file pointer
  * @param  string    $dir  target dir path
  * @param  string    $name file name
  * @param  array     $stat file stat (required by some virtual fs)
  * @return bool|string
  **/
 protected function _save($fp, $dir, $name, $stat)
 {
     $path = $this->_joinPath($dir, $name);
     $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
     $config = [];
     if (isset(self::$mimetypes[$ext])) {
         $config['mimetype'] = self::$mimetypes[$ext];
     }
     return $this->_resultPath($this->fs->putStream($path, $fp, $config), $path);
     return false;
 }
开发者ID:hectorgarcia83,项目名称:plataforma_eliana,代码行数:21,代码来源:Driver.php

示例10: putStream

 /**
  * Create a file or update if exists.
  *
  * @param string   $path     The path to the file.
  * @param resource $resource The file handle.
  * @param array    $config   An optional configuration array.
  *
  * @throws \League\Flysystem\InvalidArgumentException Thrown if $resource is not a resource.
  *
  * @return bool True on success, false on failure.
  */
 public function putStream($path, $resource, array $config = [])
 {
     return $this->fileSystem->putStream($path, $resource, $config);
 }
开发者ID:graze,项目名称:data-file,代码行数:15,代码来源:FilesystemWrapper.php


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