FilesystemAdapter
class FilesystemAdapter implements Cloud mixin FilesystemOperator
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected array | $config | The filesystem configuration. |
|
| protected PathPrefixer | $prefixer | The Flysystem PathPrefixer instance. |
|
| protected PathNormalizer | $pathNormalizer | The Flysystem path normalizer instance. |
|
| protected Closure|null | $serveCallback | The file server callback. |
|
| protected Closure|null | $temporaryUrlCallback | The temporary URL builder callback. |
|
| protected Closure|null | $temporaryUploadUrlCallback | The temporary upload URL builder callback. |
Methods
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Copy a file to another disk.
Move a file to another disk.
Transfer a file without holding a source lease during the destination write.
Mix another object into the class.
Dynamically handle calls to the class.
Pass dynamic methods call onto Flysystem.
Create a new filesystem adapter instance.
Assert that the given file or directory exists.
Assert that the number of files in path equals the expected count.
Assert that the given file or directory does not exist.
Assert that the given directory is empty.
Assert that the disk contains no files.
Determine if a file or directory exists.
Determine if a file or directory is missing.
Determine if a file exists.
Determine if a file is missing.
Determine if a directory exists.
Determine if a directory is missing.
Get the full path to the file that exists at the given relative path.
Get the contents of a file.
Get the contents of a file as decoded JSON.
Create a streamed response for a given file.
Create a streamed download response for a given file.
Build a file response using the supplied request context.
Write the contents of a file.
Store the uploaded file on the disk.
Store the uploaded file on the disk with a given name.
Get the visibility for the given path.
Set the visibility for the given path.
Prepend to a file.
Append to a file.
Delete the file at a given path.
Copy a file to a new location.
Move a file to a new location.
Get the file size of a given file.
Get the checksum for a file.
Get the mime-type of a given file.
Get the file's last modification time.
Get a resource to read the file.
Get a resource to read the partial file.
Normalize and validate byte-range stream arguments.
Write a new file using a stream.
Get the URL for the file at the given path.
Get the URL for the file at the given path.
Get the URL for the file at the given path.
Determine if temporary URLs can be generated.
Determine if temporary upload URLs can be generated.
Get a temporary URL for the file at the given path.
Get a temporary upload URL for the file at the given path.
Encode a path for use in a URL.
Encode and concatenate a path to a URL.
Replace the scheme, host and port of the given UriInterface with values from the given URL.
Get an array of all files in a directory.
Get all of the files from the given directory (recursive).
Get all of the directories within a given directory.
Get all the directories within a given directory (recursive).
Create a directory.
Recursively delete a directory.
Get the Flysystem driver.
Get the Flysystem adapter.
Get the configuration values.
Parse the given visibility value.
Define a custom temporary upload URL builder callback.
Prepare a temporary URL callback for direct invocation.
Determine if Flysystem exceptions should be thrown.
Determine if Flysystem exceptions should be reported.
Flush all static state.
Details
in
Conditionable at line 23
mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
in
Conditionable at line 56
mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
in
TransfersFiles at line 21
bool
copyToDisk(Filesystem|string|UnitEnum $disk, string $from, string|null $to = null)
Copy a file to another disk.
in
TransfersFiles at line 33
bool
moveToDisk(Filesystem|string|UnitEnum $disk, string $from, string|null $to = null)
Move a file to another disk.
in
TransfersFiles at line 41
protected bool
transferFile(Filesystem $source, string $from, Filesystem $destination, string $to)
Transfer a file without holding a source lease during the destination write.
in
Macroable at line 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
at line 1188
mixed
__call(string $method, array $parameters)
Pass dynamic methods call onto Flysystem.
at line 103
__construct(FilesystemOperator $driver, FilesystemAdapter $adapter, array $config = [])
Create a new filesystem adapter instance.
at line 122
FilesystemAdapter
assertExists(array|string $path, string|null $content = null)
Assert that the given file or directory exists.
at line 151
FilesystemAdapter
assertCount(string $path, int $count, bool $recursive = false)
Assert that the number of files in path equals the expected count.
at line 169
FilesystemAdapter
assertMissing(array|string $path)
Assert that the given file or directory does not exist.
at line 188
FilesystemAdapter
assertDirectoryEmpty(string $path)
Assert that the given directory is empty.
at line 201
FilesystemAdapter
assertEmpty()
Assert that the disk contains no files.
at line 211
bool
exists(string $path)
Determine if a file or directory exists.
at line 219
bool
missing(string $path)
Determine if a file or directory is missing.
at line 227
bool
fileExists(string $path)
Determine if a file exists.
at line 235
bool
fileMissing(string $path)
Determine if a file is missing.
at line 243
bool
directoryExists(string $path)
Determine if a directory exists.
at line 251
bool
directoryMissing(string $path)
Determine if a directory is missing.
at line 259
string
path(string $path)
Get the full path to the file that exists at the given relative path.
at line 267
string|null
get(string $path)
Get the contents of a file.
at line 285
array|bool|float|int|string|null
json(string $path, int $flags = 0)
Get the contents of a file as decoded JSON.
at line 297
StreamedResponse
response(string $path, string|null $name = null, array $headers = [], string $disposition = 'inline')
Create a streamed response for a given file.
at line 317
Response
serve(Request $request, string $path, string|null $name = null, array $headers = [])
Create a streamed response for serving a given file.
at line 329
StreamedResponse
download(string $path, string|null $name = null, array $headers = [])
Create a streamed download response for a given file.
at line 337
Image
image(string $path)
Create an image instance from a file in storage.
at line 348
protected StreamedResponse
buildFileResponse(Request $request, string $path, string|null $name, array $headers, string $disposition)
Build a file response using the supplied request context.
at line 376
bool|string
put(string $path, mixed $contents, mixed $options = [])
Write the contents of a file.
at line 416
false|string
putFile(string|File|UploadedFile $path, array|string|File|UploadedFile|null $file = null, mixed $options = [])
Store the uploaded file on the disk.
at line 430
false|string
putFileAs(string|File|UploadedFile $path, array|string|File|UploadedFile|null $file, array|string|null $name = null, mixed $options = [])
Store the uploaded file on the disk with a given name.
at line 467
string
getVisibility(string $path)
Get the visibility for the given path.
at line 479
bool
setVisibility(string $path, string $visibility)
Set the visibility for the given path.
at line 499
bool
prepend(string $path, string $data, string $separator = PHP_EOL)
Prepend to a file.
at line 517
bool
append(string $path, string $data, string $separator = PHP_EOL)
Append to a file.
at line 535
bool
delete(array|string $paths)
Delete the file at a given path.
at line 561
bool
copy(string $from, string $to)
Copy a file to a new location.
at line 581
bool
move(string $from, string $to)
Move a file to a new location.
at line 601
int
size(string $path)
Get the file size of a given file.
at line 611
false|string
checksum(string $path, array $options = [])
Get the checksum for a file.
at line 631
false|string
mimeType(string $path)
Get the mime-type of a given file.
at line 649
int
lastModified(string $path)
Get the file's last modification time.
at line 659
mixed
readStream(string $path)
Get a resource to read the file.
at line 679
mixed
readStreamRange(string $path, int|null $start, int|null $end)
Get a resource to read the partial file.
at line 766
protected array
normalizeStreamRange(int|null $start, int|null $end)
Normalize and validate byte-range stream arguments.
at line 788
bool
writeStream(string $path, mixed $resource, array $options = [])
Write a new file using a stream.
at line 810
string
url(string $path)
Get the URL for the file at the given path.
at line 836
protected string
getFtpUrl(string $path)
Get the URL for the file at the given path.
at line 846
protected string
getLocalUrl(string $path)
Get the URL for the file at the given path.
at line 870
bool
providesTemporaryUrls()
Determine if temporary URLs can be generated.
at line 878
bool
providesTemporaryUploadUrls()
Determine if temporary upload URLs can be generated.
at line 888
string
temporaryUrl(string $path, DateTimeInterface $expiration, array $options = [])
Get a temporary URL for the file at the given path.
at line 910
array|string
temporaryUploadUrl(string $path, DateTimeInterface $expiration, array $options = [])
Get a temporary upload URL for the file at the given path.
at line 930
protected string
encodeUrlPath(string $path)
Encode a path for use in a URL.
at line 938
protected string
concatPathToUrl(string $url, string $path)
Encode and concatenate a path to a URL.
at line 946
protected UriInterface
replaceBaseUrl(UriInterface $uri, string $url)
Replace the scheme, host and port of the given UriInterface with values from the given URL.
at line 961
array
files(string|null $directory = null, bool $recursive = false)
Get an array of all files in a directory.
at line 979
array
allFiles(string|null $directory = null)
Get all of the files from the given directory (recursive).
at line 989
array
directories(string|null $directory = null, bool $recursive = false)
Get all of the directories within a given directory.
at line 1006
array
allDirectories(string|null $directory = null)
Get all the directories within a given directory (recursive).
at line 1014
bool
makeDirectory(string $path)
Create a directory.
at line 1034
bool
deleteDirectory(string $directory)
Recursively delete a directory.
at line 1054
FilesystemOperator
getDriver()
Get the Flysystem driver.
at line 1062
FilesystemAdapter
getAdapter()
Get the Flysystem adapter.
at line 1070
array
getConfig()
Get the configuration values.
at line 1080
protected string|null
parseVisibility(string|null $visibility)
Parse the given visibility value.
at line 1099
void
serveUsing(Closure|null $callback)
Define a custom callback that generates file download responses.
Boot-only. The callback persists on the cached disk adapter for the worker lifetime and runs on every subsequent serve() call for that disk.
at line 1111
void
buildTemporaryUrlsUsing(Closure|null $callback)
Define a custom temporary URL builder callback.
Boot-only. The callback persists on the cached disk adapter for the worker lifetime and runs on every subsequent temporary URL generation for that disk.
at line 1123
void
buildTemporaryUploadUrlsUsing(Closure|null $callback)
Define a custom temporary upload URL builder callback.
Boot-only. The callback persists on the cached disk adapter for the worker lifetime and runs on every subsequent temporary upload URL generation for that disk.
at line 1131
protected Closure|null
prepareTemporaryUrlCallback(Closure|null $callback)
Prepare a temporary URL callback for direct invocation.
at line 1150
protected bool
throwsExceptions()
Determine if Flysystem exceptions should be thrown.
at line 1160
protected void
report(Throwable $exception)
Report the exception.
at line 1170
protected bool
shouldReport()
Determine if Flysystem exceptions should be reported.
at line 1178
static void
flushState()
Flush all static state.