2declare(strict_types=1);
12use League\Flysystem\FileExistsException;
13use League\Flysystem\FilesystemInterface;
53 $resource = $this->flySystemFS->readStream($path);
54 if ($resource ===
false) {
55 throw new IOException(
"Could not open stream for file \"$path\"");
81 $resource = $stream->detach();
83 if (!is_resource($resource)) {
84 throw new \InvalidArgumentException(
'The given stream must not be detached.');
87 $result = $this->flySystemFS->writeStream($path, $resource);
90 throw new IOException(
"Could not write stream to file \"$path\"");
92 }
catch (FileExistsException $ex) {
95 if (is_resource($resource)) {
116 $resource = $stream->detach();
118 if (!is_resource($resource)) {
119 throw new \InvalidArgumentException(
'The given stream must not be detached.');
122 $result = $this->flySystemFS->putStream($path, $resource);
125 throw new IOException(
"Could not put stream content into \"$path\"");
128 if (is_resource($resource)) {
149 $resource = $stream->detach();
151 if (!is_resource($resource)) {
152 throw new \InvalidArgumentException(
'The given stream must not be detached.');
155 $result = $this->flySystemFS->updateStream($path, $resource);
158 throw new IOException(
"Could not update file \"$path\"");
163 if (is_resource($resource)) {
An exception for terminatinating execution or to throw for unit testing.
Class FileAlreadyExistsException.
Class FileNotFoundException Indicates that a file is missing or not found.
Class IOException Indicates general problems with the input or output operations.
Class FlySystemFileStreamAccess Streaming access implementation of the fly system library.
readStream(string $path)
Opens a readable stream of the file.
updateStream(string $path, FileStream $stream)
Updates an existing file.
writeStream(string $path, FileStream $stream)
Writes the stream to a new file.
__construct(FilesystemInterface $flySystemFS)
FlySystemFileStreamAccess constructor.
putStream(string $path, FileStream $stream)
Creates a new file or updates an existing one.
Class Streams Stream factory which enables the user to create streams without the knowledge of the co...
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
Interface FileStreamAccess This interface describes all streaming filesystem operations.
Interface FileStream The base interface for all filesystem streams.