19 declare(strict_types=1);
41 private FilesystemOperator $flysystem_operator
53 $resource = $this->flysystem_operator->readStream($path);
54 if ($resource ===
false) {
55 throw new IOException(
"Could not open stream for file \"$path\"");
58 }
catch (UnableToRetrieveMetadata|UnableToReadFile $ex) {
73 $resource = $stream->detach();
74 if (!is_resource($resource)) {
75 throw new \InvalidArgumentException(
'The given stream must not be detached.');
77 if ($this->flysystem_operator->fileExists($path)) {
81 $this->flysystem_operator->writeStream($path, $resource);
82 }
catch (UnableToWriteFile $ex) {
83 throw new IOException(
"Could not write stream to file \"$path\"", 0, $ex);
85 if (is_resource($resource)) {
98 $resource = $stream->detach();
100 if (!is_resource($resource)) {
101 throw new \InvalidArgumentException(
'The given stream must not be detached.');
104 $result = $this->flysystem_operator->putStream($path, $resource);
106 if ($result ===
false) {
107 throw new IOException(
"Could not put stream content into \"$path\"");
110 if (is_resource($resource)) {
125 $resource = $stream->detach();
127 if (!is_resource($resource)) {
128 throw new \InvalidArgumentException(
'The given stream must not be detached.');
131 $this->flysystem_operator->writeStream($path, $resource);
132 }
catch (UnableToWriteFile $ex) {
135 if (is_resource($resource)) {
Indicates general problems with the input or output operations.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
updateStream(string $path, FileStream $stream)
Updates an existing file.
readStream(string $path)
Opens a readable stream of the file.
Indicates that a file is missing or not found.
__construct(private FilesystemOperator $flysystem_operator)
writeStream(string $path, FileStream $stream)
Writes the stream to a new file.
The base interface for all filesystem streams.
putStream(string $path, FileStream $stream)
Creates a new file or updates an existing one.