本文整理汇总了PHP中League\Flysystem\Filesystem::updateStream方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::updateStream方法的具体用法?PHP Filesystem::updateStream怎么用?PHP Filesystem::updateStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::updateStream方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeStream
public function writeStream($path, $resource)
{
try {
return $this->filesystem->writeStream($path, $resource);
} catch (FileExistsException $exception) {
return $this->filesystem->updateStream($path, $resource);
}
}
示例2: testUpdateStream
/**
* 1.txt
* 2.txt.
*/
public function testUpdateStream()
{
$stream = tmpfile();
fwrite($stream, 'OSS text2');
rewind($stream);
$this->assertTrue($this->filesystem->updateStream('2.txt', $stream));
fclose($stream);
}
示例3:
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();
}
示例4: testUpdateStreamFail
/**
* @expectedException InvalidArgumentException
*/
public function testUpdateStreamFail()
{
$adapter = Mockery::mock('League\\Flysystem\\AdapterInterface');
$adapter->shouldReceive('has')->andReturn(true);
$filesystem = new Filesystem($adapter);
$filesystem->updateStream('file.txt', 'not a resource');
}
示例5: updateStream
/**
* @inheritdoc
*/
public function updateStream($path, $resource, array $config = [])
{
try {
return $this->fileSystem->updateStream($this->getInnerPath($path), $resource, $config);
} catch (FileNotFoundException $e) {
throw $this->exceptionWrapper($e, $path);
}
}
示例6: 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 = [])
{
$result = parent::updateStream($path, $resource, $config);
if ($result && ($resource = $this->get($path))) {
return $this->dispatch(new SyncFile($resource));
}
return $result;
}
示例7: testUpdateStreamInvalid
public function testUpdateStreamInvalid()
{
$this->setExpectedException('InvalidArgumentException');
$this->filesystem->updateStream('path.txt', '__INVALID__');
}
示例8: updateStream
/**
* @inheritdoc
*/
public function updateStream($path, $resource, array $config = [])
{
try {
return parent::updateStream($path, $resource, $config);
} catch (\Exception $e) {
$this->errors[] = $e->getMessage();
}
return false;
}