19declare(strict_types=1);
29use League\Flysystem\FilesystemOperator;
30use League\Flysystem\UnableToWriteFile;
31use League\Flysystem\UnableToRetrieveMetadata;
32use League\Flysystem\UnableToReadFile;
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 that a file is missing or not found.
Indicates general problems with the input or output operations.
readStream(string $path)
Opens a readable stream of the file.
updateStream(string $path, FileStream $stream)
Updates an existing file.
__construct(private FilesystemOperator $flysystem_operator)
writeStream(string $path, FileStream $stream)
Writes the stream to a new file.
putStream(string $path, FileStream $stream)
Creates a new file or updates an existing one.
Stream factory which enables the user to create streams without the knowledge of the concrete class.
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
The base interface for all filesystem streams.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...