19 declare(strict_types=1);
43 private FilesystemOperator $flysystem_operator
55 $resource = $this->flysystem_operator->readStream($path);
56 if ($resource ===
false) {
57 throw new IOException(
"Could not open stream for file \"$path\"");
60 }
catch (UnableToRetrieveMetadata|UnableToReadFile $ex) {
75 $resource = $stream->detach();
76 if (!is_resource($resource)) {
77 throw new \InvalidArgumentException(
'The given stream must not be detached.');
79 if ($this->flysystem_operator->fileExists($path)) {
83 $this->flysystem_operator->writeStream($path, $resource);
84 }
catch (UnableToWriteFile $ex) {
85 throw new IOException(
"Could not write stream to file \"$path\"", 0, $ex);
87 if (is_resource($resource)) {
100 $resource = $stream->detach();
102 if (!is_resource($resource)) {
103 throw new \InvalidArgumentException(
'The given stream must not be detached.');
106 $result = $this->flysystem_operator->putStream($path, $resource);
108 if ($result ===
false) {
109 throw new IOException(
"Could not put stream content into \"$path\"");
112 if (is_resource($resource)) {
127 $resource = $stream->detach();
129 if (!is_resource($resource)) {
130 throw new \InvalidArgumentException(
'The given stream must not be detached.');
133 $this->flysystem_operator->writeStream($path, $resource);
134 }
catch (UnableToWriteFile $ex) {
137 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.