本文整理汇总了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));
}
}
示例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;
}
}
示例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);
}
示例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);
}