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


PHP Filesystem::readStream方法代码示例

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


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

示例1: downloadAttachment

 /**
  * @param $filePath
  * @param $toBeDownloadedFileName
  *
  * @return int
  */
 public function downloadAttachment($filePath, $toBeDownloadedFileName = '')
 {
     if (!is_readable($this->currentPath . $filePath)) {
         $this->setError(self::ERROR_ATTACHMENT_FILE_DOES_NOT_EXIST);
     }
     if (empty($toBeDownloadedFileName)) {
         $toBeDownloadedFileName = basename($filePath);
         if (empty($toBeDownloadedFileName)) {
             $this->setError(self::ERROR_ATTACHMENT_DOES_NOT_EXIST);
         }
     }
     if ($this->hasError()) {
         return $this->errors;
     }
     $this->setHeadersForAttachmentDownload($toBeDownloadedFileName);
     if ($this->fileSystem->getSize($filePath) > DirectoryStructure::FS_DOWNLOAD_STREAM_AFTER_SIZE) {
         header('Content-Length: ' . $this->fileSystem->getSize($filePath));
         $stream = $this->fileSystem->readStream($filePath);
         while (!feof($stream)) {
             print fgets($stream, 1024);
             flush();
         }
         fclose($stream);
         exit;
     } else {
         ob_start();
         ob_start("ob_gzhandler");
         echo $this->fileSystem->get($filePath)->read();
         ob_end_flush();
         $gzippedContent = ob_get_contents();
         // store gzipped content to get size
         header('Content-Length: ' . strlen($gzippedContent));
         ob_end_flush();
         exit;
     }
 }
开发者ID:arbi,项目名称:MyCode,代码行数:42,代码来源:GenericDownloader.php

示例2: getArchive

 /**
  * {@inheritdoc}
  */
 public function getArchive(JobExecution $jobExecution, $key)
 {
     $archives = $this->getArchives($jobExecution);
     if (!isset($archives[$key])) {
         throw new \InvalidArgumentException(sprintf('Key "%s" does not exist', $key));
     }
     return $this->filesystem->readStream($archives[$key]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:11,代码来源:AbstractFilesystemArchiver.php

示例3: testReadStream

 public function testReadStream()
 {
     $adapter = Mockery::mock('League\\Flysystem\\AdapterInterface');
     $adapter->shouldReceive('has')->andReturn(true);
     $adapter->shouldReceive('readStream')->twice()->andReturn(array('stream' => 'this result'), false);
     $filesystem = new Filesystem($adapter);
     $this->assertEquals('this result', $filesystem->readStream('file.txt'));
     $this->assertFalse($filesystem->readStream('other.txt'));
     // Another time to hit the cache
     $this->assertEquals('this result', $filesystem->readStream('file.txt'));
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:11,代码来源:FlysystemStreamTests.php

示例4: testReadStream

 public function testReadStream()
 {
     $adapter = Mockery::mock('League\\Flysystem\\AdapterInterface');
     $adapter->shouldReceive('has')->andReturn(true);
     $stream = tmpfile();
     $adapter->shouldReceive('readStream')->times(3)->andReturn(['stream' => $stream], false, false);
     $filesystem = new Filesystem($adapter);
     $this->assertInternalType('resource', $filesystem->readStream('file.txt'));
     $this->assertFalse($filesystem->readStream('other.txt'));
     fclose($stream);
     $this->assertFalse($filesystem->readStream('other.txt'));
 }
开发者ID:mechiko,项目名称:staff-october,代码行数:12,代码来源:FlysystemStreamTests.php

示例5:

 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

示例6: testReadStreamFail

 public function testReadStreamFail()
 {
     $path = 'path.txt';
     $this->prophecy->has($path)->willReturn(true);
     $this->prophecy->readStream($path)->willReturn(false);
     $response = $this->filesystem->readStream($path);
     $this->assertFalse($response);
 }
开发者ID:mechiko,项目名称:staff-october,代码行数:8,代码来源:FilesystemTests.php

示例7: readStream

 /**
  * @inheritdoc
  */
 public function readStream($path)
 {
     try {
         return $this->fileSystem->readStream($this->getInnerPath($path));
     } catch (FileNotFoundException $e) {
         throw $this->exceptionWrapper($e, $path);
     }
 }
开发者ID:petrknap,项目名称:php-filestorage,代码行数:11,代码来源:FileSystem.php

示例8: testPushNotExists

 public function testPushNotExists()
 {
     $file = '123-123-123';
     $path = sprintf('%s/%s.zip', $this->name, $file);
     $this->localFilesystem->readStream($path)->willReturn(false);
     $this->remoteFilesystem->putStream($path, Argument::any())->shouldNotBeCalled();
     $this->storage->push($file);
 }
开发者ID:nanbando,项目名称:core,代码行数:8,代码来源:LocalStorageTest.php

示例9: push

 /**
  * {@inheritdoc}
  */
 public function push($file)
 {
     if (!$this->remoteFilesystem) {
         throw new RemoteStorageNotConfiguredException();
     }
     $path = sprintf('%s/%s.zip', $this->name, $file);
     if (false === ($stream = $this->localFilesystem->readStream($path)) || $this->remoteFilesystem->has($path)) {
         return;
     }
     $this->remoteFilesystem->putStream($path, $stream);
 }
开发者ID:nanbando,项目名称:core,代码行数:14,代码来源:LocalStorage.php

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

示例11: fopen

 /**
  * {@inheritdoc}
  */
 public function fopen($path, $mode)
 {
     $fullPath = $this->buildPath($path);
     $useExisting = true;
     switch ($mode) {
         case 'r':
         case 'rb':
             try {
                 return $this->flysystem->readStream($fullPath);
             } catch (FileNotFoundException $e) {
                 return false;
             }
         case 'w':
         case 'w+':
         case 'wb':
         case 'wb+':
             $useExisting = false;
         case 'a':
         case 'ab':
         case 'r+':
         case 'a+':
         case 'x':
         case 'x+':
         case 'c':
         case 'c+':
             //emulate these
             if ($useExisting and $this->file_exists($path)) {
                 if (!$this->isUpdatable($path)) {
                     return false;
                 }
                 $tmpFile = $this->getCachedFile($path);
             } else {
                 if (!$this->isCreatable(dirname($path))) {
                     return false;
                 }
                 $tmpFile = \OCP\Files::tmpFile();
             }
             $source = fopen($tmpFile, $mode);
             return CallbackWrapper::wrap($source, null, null, function () use($tmpFile, $fullPath) {
                 $this->flysystem->putStream($fullPath, fopen($tmpFile, 'r'));
                 unlink($tmpFile);
             });
     }
     return false;
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:48,代码来源:Flysystem.php

示例12:

 function it_should_unsuccessfully_read_stream_from_remote_file($path, Filesystem $filesystem)
 {
     $filesystem->readStream($path)->willReturn(false);
     $this->readStream($path)->shouldReturn(false);
     $filesystem->readStream($path)->shouldBeCalled();
 }
开发者ID:devhelp,项目名称:backup,代码行数:6,代码来源:SourceFlysystemAdapterSpec.php

示例13: testReadStream

 public function testReadStream()
 {
     $this->assertInternalType('resource', $this->filesystem->readStream('2.txt'));
 }
开发者ID:apollopy,项目名称:flysystem-aliyun-oss,代码行数:4,代码来源:AliyunOssAdapterTest.php

示例14: moveToTrash

 /**
  * Moves a file from somewhere to the expired trash heap
  *
  * @param Filesystem $filesystem
  * @param string     $filename
  * @param array      $config An optional configuration array
  *
  * @return bool
  */
 protected function moveToTrash(Filesystem $filesystem, $filename, array $config = [])
 {
     if (config('snapshot.soft-delete', EnterpriseDefaults::SNAPSHOT_SOFT_DELETE)) {
         $_trash = InstanceStorage::getTrashMount('expired');
         if ($_trash->writeStream($filename, $filesystem->readStream($filename), $config)) {
             return $filesystem->delete($filename);
         }
         //  Try and remove any partial file created before failure
         try {
             $_trash->delete($filename);
         } catch (\Exception $_ex) {
             //  Ignored, this is a cleanup in case of failure...
         }
     } else {
         try {
             if ($filesystem->has($filename)) {
                 return $filesystem->delete($filename);
             }
             //  It's gone
             return true;
         } catch (\Exception $_ex) {
             //  Can't delete? not good
             return false;
         }
     }
     return false;
 }
开发者ID:rajeshpillai,项目名称:dfe-console,代码行数:36,代码来源:RouteHashingService.php

示例15: execute

 /**
  * @throws \InvalidArgumentException
  */
 public function execute()
 {
     $this->destinationFilesystem->writeStream($this->destinationPath, $this->sourceFilesystem->readStream($this->sourcePath));
 }
开发者ID:parabol,项目名称:laravel-cms,代码行数:7,代码来源:TransferFile.php


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