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


PHP Filesystem::writeStream方法代码示例

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


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

示例1: saveFile

 /**
  * {@inheritdoc}
  */
 public function saveFile(UploadedFile $uploadedFile, $fileName)
 {
     $stream = fopen($uploadedFile->getRealPath(), 'r+');
     $result = $this->filesystem->writeStream($this->getMediaBasePath() . '/' . $fileName . '.' . $uploadedFile->guessClientExtension(), $stream);
     fclose($stream);
     return $result;
 }
开发者ID:superdesk,项目名称:web-publisher,代码行数:10,代码来源:MediaManager.php

示例2: writeStream

 public function writeStream($path, $resource)
 {
     try {
         return $this->filesystem->writeStream($path, $resource);
     } catch (FileExistsException $exception) {
         return $this->filesystem->updateStream($path, $resource);
     }
 }
开发者ID:devhelp,项目名称:backup,代码行数:8,代码来源:TargetFlysystemAdapter.php

示例3: testWriteStream

 /**
  * 1.txt
  * 2.txt.
  */
 public function testWriteStream()
 {
     $stream = tmpfile();
     fwrite($stream, 'OSS text');
     rewind($stream);
     $this->assertTrue($this->filesystem->writeStream('2.txt', $stream));
     fclose($stream);
 }
开发者ID:apollopy,项目名称:flysystem-aliyun-oss,代码行数:12,代码来源:AliyunOssAdapterTest.php

示例4:

 function it_should_successfully_update_stream($path, Filesystem $filesystem)
 {
     $filesystem->writeStream($path, 'resource2')->willThrow('League\\Flysystem\\FileExistsException');
     $filesystem->updateStream($path, 'resource2')->willReturn(true);
     $this->writeStream($path, 'resource2');
     $filesystem->writeStream($path, 'resource2')->shouldBeCalled();
     $filesystem->updateStream($path, 'resource2')->shouldBeCalled();
 }
开发者ID:devhelp,项目名称:backup,代码行数:8,代码来源:TargetFlysystemAdapterSpec.php

示例5: persist

 /**
  * {@inheritdoc}
  */
 public function persist(File $file) : bool
 {
     // only write temporary, i.e. not yet persisted files, to backend file storage
     if ($file->isTmpFile()) {
         // use streams for writing to backend file storage
         $stream = fopen($file->getTmpPathname(), 'r+');
         return $this->filesystem->writeStream($file->getKey(), $stream);
     }
     return true;
 }
开发者ID:reskume,项目名称:file-bundle,代码行数:13,代码来源:FlysystemAdapter.php

示例6: uploadFile

 /**
  * @param string $fileName
  * @return bool
  */
 public function uploadFile($fileName)
 {
     if (true === $this->fileExists($fileName)) {
         $fileStream = $this->openFile($fileName, 'r');
         $result = $this->fileSystem->writeStream($this->getFileNameFromPath($fileName), $fileStream);
         $this->closeFile($fileStream);
         return false !== $result;
     }
     return false;
 }
开发者ID:TransformCore,项目名称:HayPersistenceApi,代码行数:14,代码来源:FileUploadService.php

示例7: store

 /**
  * @param array $fileList
  */
 public function store(array $fileList)
 {
     foreach ($fileList as $file) {
         $this->logger->notice('Storing ' . $file . ' in s3 bucket ' . $this->filesystem->getAdapter()->getBucket());
         try {
             $stream = fopen($file, 'r');
             $this->filesystem->writeStream($this->getStoredFilename($file), $stream, ['visibility' => AdapterInterface::VISIBILITY_PRIVATE]);
         } catch (\Exception $e) {
             $this->logger->error('Exception while storing ' . $file . ': ' . $e->getMessage());
         }
         if (isset($stream) && is_resource($stream)) {
             fclose($stream);
         }
     }
 }
开发者ID:TomAdam,项目名称:db-backup,代码行数:18,代码来源:S3StorageAdapter.php

示例8:

 function it_should_execute_the_transfer_file_command(Filesystem $source, Filesystem $destination)
 {
     $source->readStream('source')->willReturn('data');
     $destination->writeStream('destination', 'data')->shouldBeCalled();
     $this->beConstructedWith($source, 'source', $destination, 'destination');
     $this->execute();
 }
开发者ID:alibo,项目名称:backup-manager,代码行数:7,代码来源:TransferFileSpec.php

示例9: testWriteStreamFail

 /**
  * @expectedException InvalidArgumentException
  */
 public function testWriteStreamFail()
 {
     $adapter = Mockery::mock('League\\Flysystem\\AdapterInterface');
     $adapter->shouldReceive('has')->andReturn(false);
     $filesystem = new Filesystem($adapter);
     $filesystem->writeStream('file.txt', 'not a resource');
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:10,代码来源:FlysystemStreamTests.php

示例10: handle

 /**
  * Saves the file with a unique file name.
  *
  * @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
  * @param string $directory what subdirectory to upload the file into
  * @return mixed If the Flysystem transfer succeeded, returns the final
  *   file name used.
  */
 public function handle(UploadedFile $file = null, $directory = null)
 {
     if (null == $file) {
         return null;
     }
     $stream = fopen($file->getRealPath(), 'r+');
     $this->fileNameGenerator->setFilename($file->getClientOriginalName());
     if (null === $directory) {
         $directory = '';
     }
     do {
         $filename = $this->fileNameGenerator->nextName();
     } while ($this->flysystem->has($directory . $filename));
     // TODO error not being handled
     $result = $this->flysystem->writeStream($directory . $filename, $stream);
     return $filename;
 }
开发者ID:npmweb,项目名称:upload-handler,代码行数:25,代码来源:FlysystemUploadHandler.php

示例11: writeStream

 /**
  * Write a new file using a stream.
  *
  * @param string   $path     The path of the new file.
  * @param resource $resource The file handle.
  * @param array    $config   An optional configuration array.
  *
  * @throws InvalidArgumentException If $resource is not a file handle.
  * @throws FileExistsException
  *
  * @return bool True on success, false on failure.
  */
 public function writeStream($path, $resource, array $config = [])
 {
     $result = parent::writeStream($path, $resource, $config);
     if ($result && ($resource = $this->get($path))) {
         return $this->dispatch(new SyncFile($resource));
     }
     return $result;
 }
开发者ID:ramcda,项目名称:files-module,代码行数:20,代码来源:AdapterFilesystem.php

示例12: backup

 /**
  * {@inheritdoc}
  */
 public function backup(Filesystem $source, Filesystem $destination, Database $database, array $parameter)
 {
     $this->output->writeln('  * <comment>export "' . $parameter['path'] . '" to "export.xml"</comment>');
     $tempfile = $this->temporaryFileSystem->createTemporaryFile('jackrabbit');
     $stream = fopen($tempfile, 'w+');
     $this->export($this->getSession($parameter), $parameter['path'], $stream);
     fclose($stream);
     $destination->writeStream('export.xml', fopen($tempfile, 'r'));
 }
开发者ID:nanbando,项目名称:jackrabbit,代码行数:12,代码来源:JackrabbitPlugin.php

示例13: FileExistsException

 function it_throws_an_exception_if_the_file_already_exists_on_the_filesystem($mountManager, $factory, \SplFileInfo $rawFile, Filesystem $fs, FileInfoInterface $fileInfo)
 {
     $rawFile->getPathname()->willReturn(__FILE__);
     $fs->has(Argument::any())->willReturn(true);
     $fs->writeStream(Argument::any(), Argument::any())->willThrow(new FileExistsException('The file exists.'));
     $mountManager->getFilesystem('destination')->willReturn($fs);
     $factory->createFromRawFile($rawFile, 'destination')->willReturn($fileInfo);
     $fileInfo->getKey()->willReturn('key-file');
     $this->shouldThrow(new FileTransferException(sprintf('Unable to move the file "%s" to the "destination" filesystem.', __FILE__)))->during('store', [$rawFile, 'destination']);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:10,代码来源:FileStorerSpec.php

示例14: deployToRemote

 /**
  * Deploy files to the remote filesystem.
  *
  * @return void
  */
 public function deployToRemote()
 {
     $local_path = $this->relativeDumpPath();
     $files = $this->localAdapter->listContents($local_path);
     foreach ($files as $file) {
         $contents = $this->localAdapter->readStream($local_path . $file['basename']);
         $file_size = $this->localAdapter->getSize($local_path . $file['basename']);
         $this->out($this->parseString('Uploading %s (%s)', [$file['basename'], $this->formatBytes($file_size)], 'light_green'));
         $this->remoteAdapter->writeStream($local_path . $file['basename'], $contents);
     }
 }
开发者ID:JayBizzle,项目名称:mysqldumper,代码行数:16,代码来源:MySQLDumperCommand.php

示例15: doBackup

 /**
  * @return mixed
  */
 public function doBackup()
 {
     $date = date('YmdHisO');
     $dumpName = trim($this->options->getPath() . $date . '.sql', '/');
     switch ($this->dumperOptions->getCompress()) {
         case Mysqldump::GZIP:
             $dumpName = $dumpName . '.gz';
             break;
         case Mysqldump::BZIP2:
             $dumpName = $dumpName . '.bz2';
             break;
     }
     $tmpFile = tempnam(sys_get_temp_dir(), 'bsb-flysystem-mysql-backup-');
     $fileStream = fopen($tmpFile, 'rb');
     try {
         if (false === $fileStream) {
             throw new \RuntimeException("A temp file could not be created");
         }
         // start dump and backup
         $this->dumper->start($tmpFile);
         $this->filesystem->writeStream($dumpName, $fileStream);
         // write a latest file
         if ($this->options->getWriteLatest()) {
             $this->filesystem->put($this->options->getPath() . $this->options->getWriteLatest(), pathinfo($dumpName, PATHINFO_BASENAME));
         }
         if ($this->options->getAutoPrune()) {
             $this->pruneStorage();
         }
     } catch (\Exception $e) {
         throw new \RuntimeException($e->getMessage());
     } finally {
         if (is_resource($fileStream)) {
             fclose($fileStream);
         }
         if (file_exists($tmpFile)) {
             unlink($tmpFile);
         }
     }
     return $dumpName;
 }
开发者ID:bushbaby,项目名称:BsbFlysystemMysqlBackup,代码行数:43,代码来源:MysqlBackupService.php


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