ReadThroughFilesystem
class ReadThroughFilesystem extends FilesystemAdapter
Traits
Constants
| internal BUFFERED_STREAM_CONTEXT_OPTION |
The stream context option identifying a range over an independent buffer. |
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected array | $config | The filesystem configuration. |
from FilesystemAdapter |
| protected PathPrefixer | $prefixer | The Flysystem PathPrefixer instance. |
from FilesystemAdapter |
| protected PathNormalizer | $pathNormalizer | The Flysystem path normalizer instance. |
from FilesystemAdapter |
| protected Closure|null | $serveCallback | The file server callback. |
from FilesystemAdapter |
| protected Closure|null | $temporaryUrlCallback | The temporary URL builder callback. |
from FilesystemAdapter |
| protected Closure|null | $temporaryUploadUrlCallback | The temporary upload URL builder callback. |
from FilesystemAdapter |
| protected PathPrefixer | $readThroughPrefixer |
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.
Dynamically handle calls to the class.
Create a new read-through filesystem 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.
Get the primary filesystem path, including both disks' prefixes.
Get the contents of a file as decoded JSON.
Create a streamed response for a given file.
Create a streamed response for serving 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.
Set the visibility for the given path.
Prepend to a file.
Append to a file.
Get the checksum for a file.
Read a byte range using native cloud requests when promotion is unnecessary.
Normalize and validate byte-range stream arguments.
Write a new file using a stream.
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 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).
Run a callback with the Flysystem driver, as pooled disks do with a borrowed one.
Run a callback with the Flysystem adapter, as pooled disks do with a borrowed one.
Parse the given visibility value.
Define a custom temporary upload URL builder callback.
Prepare a temporary URL callback for direct invocation.
Determine whether failure policy or coroutine cancellation requires propagation.
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 30
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 44
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 61
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 72
static void
flushMacros()
Flush the existing macros.
Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 83
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 108
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 23
__construct(FilesystemOperator $driver, FilesystemAdapter $adapter, array $config, Cloud $primary, Cloud $fallback, string $prefix = '', ReadThroughFilesystemAdapter|null $readThroughAdapter = null)
Create a new read-through filesystem instance.
Pooled disk decorators forward adapter methods that are not on the Cloud contract.
in
FilesystemAdapter at line 133
FilesystemAdapter
assertExists(array|string $path, string|null $content = null)
Assert that the given file or directory exists.
in
FilesystemAdapter at line 164
FilesystemAdapter
assertCount(string $path, int $count, bool $recursive = false)
Assert that the number of files in path equals the expected count.
in
FilesystemAdapter at line 184
FilesystemAdapter
assertMissing(array|string $path)
Assert that the given file or directory does not exist.
in
FilesystemAdapter at line 205
FilesystemAdapter
assertDirectoryEmpty(string $path)
Assert that the given directory is empty.
in
FilesystemAdapter at line 220
FilesystemAdapter
assertEmpty()
Assert that the disk contains no files.
in
FilesystemAdapter at line 230
bool
exists(string $path)
Determine if a file or directory exists.
in
FilesystemAdapter at line 238
bool
missing(string $path)
Determine if a file or directory is missing.
in
FilesystemAdapter at line 246
bool
fileExists(string $path)
Determine if a file exists.
in
FilesystemAdapter at line 254
bool
fileMissing(string $path)
Determine if a file is missing.
in
FilesystemAdapter at line 262
bool
directoryExists(string $path)
Determine if a directory exists.
in
FilesystemAdapter at line 270
bool
directoryMissing(string $path)
Determine if a directory is missing.
at line 40
string
path(string $path)
Get the primary filesystem path, including both disks' prefixes.
in
FilesystemAdapter at line 286
string|null
get(string $path)
Get the contents of a file.
in
FilesystemAdapter at line 304
array|bool|float|int|string|null
json(string $path, int $flags = 0)
Get the contents of a file as decoded JSON.
in
FilesystemAdapter at line 316
StreamedResponse
response(string $path, string|null $name = null, array $headers = [], string $disposition = 'inline')
Create a streamed response for a given file.
in
FilesystemAdapter at line 336
Response
serve(Request $request, string $path, string|null $name = null, array $headers = [])
Create a streamed response for serving a given file.
in
FilesystemAdapter at line 348
StreamedResponse
download(string $path, string|null $name = null, array $headers = [])
Create a streamed download response for a given file.
in
FilesystemAdapter at line 356
Image
image(string $path)
Create an image instance from a file in storage.
in
FilesystemAdapter at line 367
protected StreamedResponse
buildFileResponse(Request $request, string $path, string|null $name, array $headers, string $disposition)
Build a file response using the supplied request context.
in
FilesystemAdapter at line 395
bool|string
put(string $path, mixed $contents, mixed $options = [])
Write the contents of a file.
in
FilesystemAdapter at line 444
false|string
putFile(string|File|UploadedFile $path, array|string|File|UploadedFile|null $file = null, mixed $options = [])
Store the uploaded file on the disk.
in
FilesystemAdapter at line 458
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.
in
FilesystemAdapter at line 495
string
getVisibility(string $path)
Get the visibility for the given path.
in
FilesystemAdapter at line 507
bool
setVisibility(string $path, string $visibility)
Set the visibility for the given path.
in
FilesystemAdapter at line 527
bool
prepend(string $path, string $data, string $separator = PHP_EOL)
Prepend to a file.
in
FilesystemAdapter at line 545
bool
append(string $path, string $data, string $separator = PHP_EOL)
Append to a file.
in
FilesystemAdapter at line 563
bool
delete(array|string $paths)
Delete the file at a given path.
in
FilesystemAdapter at line 589
bool
copy(string $from, string $to)
Copy a file to a new location.
in
FilesystemAdapter at line 609
bool
move(string $from, string $to)
Move a file to a new location.
in
FilesystemAdapter at line 629
int
size(string $path)
Get the file size of a given file.
in
FilesystemAdapter at line 639
false|string
checksum(string $path, array $options = [])
Get the checksum for a file.
in
FilesystemAdapter at line 659
false|string
mimeType(string $path)
Get the mime-type of a given file.
in
FilesystemAdapter at line 677
int
lastModified(string $path)
Get the file's last modification time.
in
FilesystemAdapter at line 687
mixed
readStream(string $path)
Get a resource to read the file.
at line 96
mixed
readStreamRange(string $path, int|null $start, int|null $end)
Read a byte range using native cloud requests when promotion is unnecessary.
in
FilesystemAdapter at line 801
protected array
normalizeStreamRange(int|null $start, int|null $end)
Normalize and validate byte-range stream arguments.
in
FilesystemAdapter at line 823
bool
writeStream(string $path, mixed $resource, array $options = [])
Write a new file using a stream.
at line 48
string
url(string $path)
Get the URL for the file at the given path.
in
FilesystemAdapter at line 871
protected string
getFtpUrl(string $path)
Get the URL for the file at the given path.
in
FilesystemAdapter at line 881
protected string
getLocalUrl(string $path)
Get the URL for the file at the given path.
at line 84
bool
providesTemporaryUrls()
Determine if temporary URLs can be generated.
at line 66
bool
providesTemporaryUploadUrls()
Determine if temporary upload URLs can be generated.
at line 56
string
temporaryUrl(string $path, DateTimeInterface $expiration, array $options = [])
Get a temporary URL for the file at the given path.
at line 74
array|string
temporaryUploadUrl(string $path, DateTimeInterface $expiration, array $options = [])
Get a temporary upload URL for the file at the given path.
in
FilesystemAdapter at line 965
protected string
encodeUrlPath(string $path)
Encode a path for use in a URL.
in
FilesystemAdapter at line 973
protected string
concatPathToUrl(string $url, string $path)
Encode and concatenate a path to a URL.
in
FilesystemAdapter at line 981
protected UriInterface
replaceBaseUrl(UriInterface $uri, string $url)
Replace the scheme, host and port of the given UriInterface with values from the given URL.
in
FilesystemAdapter at line 996
array
files(string|null $directory = null, bool $recursive = false)
Get an array of all files in a directory.
in
FilesystemAdapter at line 1014
array
allFiles(string|null $directory = null)
Get all of the files from the given directory (recursive).
in
FilesystemAdapter at line 1024
array
directories(string|null $directory = null, bool $recursive = false)
Get all of the directories within a given directory.
in
FilesystemAdapter at line 1041
array
allDirectories(string|null $directory = null)
Get all the directories within a given directory (recursive).
in
FilesystemAdapter at line 1049
bool
makeDirectory(string $path)
Create a directory.
in
FilesystemAdapter at line 1069
bool
deleteDirectory(string $directory)
Recursively delete a directory.
in
FilesystemAdapter at line 1089
FilesystemOperator
getDriver()
Get the Flysystem driver.
in
FilesystemAdapter at line 1097
FilesystemAdapter
getAdapter()
Get the Flysystem adapter.
in
FilesystemAdapter at line 1111
mixed
withDriver(Closure $callback)
Run a callback with the Flysystem driver, as pooled disks do with a borrowed one.
in
FilesystemAdapter at line 1125
mixed
withAdapter(Closure $callback)
Run a callback with the Flysystem adapter, as pooled disks do with a borrowed one.
in
FilesystemAdapter at line 1133
array
getConfig()
Get the configuration values.
in
FilesystemAdapter at line 1143
protected string|null
parseVisibility(string|null $visibility)
Parse the given visibility value.
in
FilesystemAdapter at line 1162
void
serveUsing(Closure|null $callback)
Define a custom callback that generates file download responses.
The callback persists on the cached disk adapter for the worker lifetime and runs on every subsequent serve() call for that disk.
in
FilesystemAdapter at line 1174
void
buildTemporaryUrlsUsing(Closure|null $callback)
Define a custom temporary URL builder callback.
The callback persists on the cached disk adapter for the worker lifetime and runs on every subsequent temporary URL generation for that disk.
in
FilesystemAdapter at line 1187
void
buildTemporaryUploadUrlsUsing(Closure|null $callback)
Define a custom temporary upload URL builder callback.
The callback persists on the cached disk adapter for the worker lifetime and runs on every subsequent temporary upload URL generation for that disk.
in
FilesystemAdapter at line 1196
protected Closure|null
prepareTemporaryUrlCallback(Closure|null $callback)
Prepare a temporary URL callback for direct invocation.
in
FilesystemAdapter at line 1215
protected bool
throwsExceptions()
Determine if Flysystem exceptions should be thrown.
in
FilesystemAdapter at line 1223
protected bool
shouldThrow(Throwable $exception)
Determine whether failure policy or coroutine cancellation requires propagation.
in
FilesystemAdapter at line 1233
protected void
report(Throwable $exception)
Report the exception.
in
FilesystemAdapter at line 1243
protected bool
shouldReport()
Determine if Flysystem exceptions should be reported.
in
FilesystemAdapter at line 1251
static void
flushState()
Flush all static state.
at line 123
protected Cloud
readerFor(string $path)
Get the filesystem that contains the given path.