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


PHP FilesystemInterface::updateStream方法代码示例

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


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

示例1: create

 public function create(BinaryFileCreateStruct $binaryFileCreateStruct)
 {
     try {
         $this->filesystem->writeStream($binaryFileCreateStruct->id, $binaryFileCreateStruct->getInputStream(), array('mimetype' => $binaryFileCreateStruct->mimeType, 'visibility' => AdapterInterface::VISIBILITY_PUBLIC));
     } catch (FileExistsException $e) {
         $this->filesystem->updateStream($binaryFileCreateStruct->id, $binaryFileCreateStruct->getInputStream(), array('mimetype' => $binaryFileCreateStruct->mimeType, 'visibility' => AdapterInterface::VISIBILITY_PUBLIC));
     }
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:8,代码来源:Flysystem.php

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

示例3: testUpdateStream

 /**
  * @dataProvider adapterProvider
  */
 public function testUpdateStream(FilesystemInterface $filesystem, $adapter, $mock)
 {
     $stream = tmpfile();
     $mock->shouldReceive('put')->andReturn(true, false);
     $mock->shouldReceive('stat')->andReturn(['type' => NET_SFTP_TYPE_DIRECTORY, 'mtime' => time(), 'size' => 20, 'permissions' => 0777]);
     $this->assertTrue($filesystem->updateStream('something', $stream));
     $this->assertFalse($filesystem->updateStream('something_else.txt', $stream));
     fclose($stream);
 }
开发者ID:raddeus,项目名称:flysystem-sftp,代码行数:12,代码来源:SftpAdapterTests.php

示例4: 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 \League\Flysystem\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 = [])
 {
     return $this->fileSystem->updateStream($path, $resource, $config);
 }
开发者ID:graze,项目名称:data-file,代码行数:16,代码来源:FilesystemWrapper.php


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