64 throw new IOException(
"Could not access the file \"$path\".");
88 return $this->flySystemFS->has(
$path);
107 $mimeType = $this->flySystemFS->getMimetype(
$path);
108 if ($mimeType ===
false) {
109 throw new IOException(
"Could not determine the MIME type of the file \"$path\".");
137 $rawTimestamp = $this->flySystemFS->getTimestamp(
$path);
138 if ($rawTimestamp ===
false) {
139 throw new IOException(
"Could not lookup timestamp of the file \"$path\".");
142 return new \DateTime($rawTimestamp);
169 $this->
nonNull($fileSizeUnit,
'fileSizeUnit');
172 $byteSize = $this->flySystemFS->getSize(
$path);
175 if ($byteSize ===
false) {
176 throw new IOException(
"Could not calculate the file size of the file \"$path\".");
207 $this->
nonNull($visibility,
'visibility');
215 return $this->flySystemFS->setVisibility(
$path, $visibility);
231 throw new \InvalidArgumentException(
"The access must be 'public' or 'private' but '$visibility' was given.");
261 $visibility = $this->flySystemFS->getVisibility(
$path);
263 if ($visibility ===
false) {
264 throw new IOException(
"Could not determine visibility for path '$path'.");
288 $this->
nonNull($content,
'content');
291 if ($this->flySystemFS->write(
$path, $content) ===
false) {
292 throw new IOException(
"Could not write to file \"$path\" because a general IO error occurred. Please check that your destination is writable.");
318 $this->
nonNull($newContent,
'newContent');
321 if ($this->flySystemFS->update(
$path, $newContent) ===
false) {
322 throw new IOException(
"Could not write to file \"$path\" because a general IO error occurred. Please check that your destination is writable.");
346 $this->
nonNull($content,
'content');
348 if ($this->flySystemFS->put(
$path, $content) ===
false) {
349 throw new IOException(
"Could not write to file \"$path\" because a general IO error occurred. Please check that your destination is writable.");
372 if ($this->flySystemFS->delete(
$path) ===
false) {
373 throw new IOException(
"Could not delete file \"$path\" because a general IO error occurred. Please check that your target is writable.");
399 $this->
delete(
$path);
423 $this->
nonNull($newPath,
'newPath');
426 if ($this->flySystemFS->rename(
$path, $newPath) ===
false) {
427 throw new IOException(
"Could not move file from \"$path\" to \"$newPath\".");
455 $this->
nonNull($copyPath,
'copyPath');
458 if ($this->flySystemFS->copy(
$path, $copyPath) ===
false) {
459 throw new IOException(
"Could not copy file \"$path\" to destination \"$copyPath\" because a general IO error occurred. Please check that your destination is writable.");
478 private function nonNull($toCheck, $parameterName)
480 if (is_null($toCheck)) {
481 throw new \InvalidArgumentException(
"The parameter \"$parameterName\" must not be null.");
readAndDelete($path)
Reads the entire file content into a string and removes the file afterwards.
getVisibility($path)
Get the file visibility.
Class FileAlreadyExistsException.
getTimestamp($path)
Get the timestamp (mtime) of the file.
copy($path, $copyPath)
Copy the source file to a destination.
setVisibility($path, $visibility)
Sets the visibility for a file.
Class FlySystemFileAccess.
rename($path, $newPath)
Moves a file from the source to the destination.
read($path)
Reads a file content to a string.
has($path)
Checks whether a file exists.
getMimeType($path)
Get a files mime-type.
put($path, $content)
Creates a file or updates an existing one.
const PRIVATE_ACCESS
Private file visibility.
update($path, $newContent)
Updates the content of a file.
getSize($path, $fileSizeUnit)
Get the size of a file.
write($path, $content)
Writes the content to a new file.
const PUBLIC_ACCESS
Public file visibility.
__construct(FilesystemInterface $flySystemFS)
FlySystemFileAccess constructor.
nonNull($toCheck, $parameterName)
Validates that the passed argument is not null or an exception is thrown.
validateVisibility($visibility)
Checks if the given visibility is valid an throws an exception otherwise.