class ClientPooledFilesystem implements Cloud

Traits

Properties

protected Closure|null $serveCallback from  InteractsWithPooledFilesystem
protected Closure|null $temporaryUrlCallback from  InteractsWithPooledFilesystem
protected Closure|null $temporaryUploadUrlCallback from  InteractsWithPooledFilesystem

Methods

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.

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.

assertExists(array|string $path, string|null $content = null)

Assert that the given file or directory exists.

assertCount(string $path, int $count, bool $recursive = false)

Assert that the number of files in path equals the expected count.

assertMissing(array|string $path)

Assert that the given file or directory does not exist.

assertDirectoryEmpty(string $path)

Assert that the given directory is empty.

assertEmpty()

Assert that the disk contains no files.

bool
exists(string $path)

Determine if a file or directory exists.

bool
missing(string $path)

Determine if a file or directory is missing.

bool
fileExists(string $path)

Determine if a file exists.

bool
fileMissing(string $path)

Determine if a file is missing.

bool
directoryExists(string $path)

Determine if a directory exists.

bool
directoryMissing(string $path)

Determine if a directory is missing.

string
path(string $path)

Get the full path to the file that exists at the given relative path.

bool
has(string $location)

Determine if a file or directory exists using the Flysystem operator.

string
read(string $location)

Read a file using the Flysystem operator.

int
fileSize(string $path)

Get a file size using the Flysystem operator.

string
visibility(string $path)

Get raw Flysystem visibility for a path.

void
write(string $location, string $contents, array $config = [])

Write a file using the Flysystem operator.

void
createDirectory(string $location, array $config = [])

Create a directory using the Flysystem operator.

string|null
get(string $path)

Get the contents of a file.

array|bool|float|int|string|null
json(string $path, int $flags = 0)

Get the contents of a file as decoded JSON.

StreamedResponse
response(string $path, string|null $name = null, array $headers = [], string $disposition = 'inline')

Create a streamed response for a given file.

Response
serve(Request $request, string $path, string|null $name = null, array $headers = [])

Create a streamed response for serving a given file.

StreamedResponse
download(string $path, string|null $name = null, array $headers = [])

Create a streamed download response for a given file.

bool|string
put(string $path, mixed $contents, mixed $options = [])

Write the contents of a file.

false|string
putFile(string|File|UploadedFile $path, array|string|File|UploadedFile|null $file = null, mixed $options = [])

Store the uploaded file on the disk.

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.

string
getVisibility(string $path)

Get the visibility for the given path.

bool
setVisibility(string $path, string $visibility)

Set the visibility for the given path.

bool
prepend(string $path, string $data, string $separator = PHP_EOL)

Prepend to a file.

bool
append(string $path, string $data, string $separator = PHP_EOL)

Append to a file.

bool
delete(array|string $paths)

Delete the file at a given path.

bool
copy(string $from, string $to)

Copy a file to a new location.

bool
move(string $from, string $to)

Move a file to a new location.

int
size(string $path)

Get the file size of a given file.

false|string
checksum(string $path, array $options = [])

Get the checksum for a file.

false|string
mimeType(string $path)

Get the mime-type of a given file.

int
lastModified(string $path)

Get the file's last modification time.

mixed
readStream(string $path)

Get a resource to read the file.

mixed
readStreamRange(string $path, int|null $start, int|null $end)

Get a resource to read the partial file.

bool
writeStream(string $path, mixed $resource, array $options = [])

Write a new file using a stream.

string
url(string $path)

Get the URL for the file at the given path.

bool
providesTemporaryUrls()

Determine if temporary URLs can be generated.

bool
providesTemporaryUploadUrls()

Determine if temporary upload URLs can be generated.

string
temporaryUrl(string $path, DateTimeInterface $expiration, array $options = [])

Get a temporary URL for the file at the given path.

array|string
temporaryUploadUrl(string $path, DateTimeInterface $expiration, array $options = [])

Get a temporary upload URL for the file at the given path.

array
files(string|null $directory = null, bool $recursive = false)

Get an array of all files in a directory.

array
allFiles(string|null $directory = null)

Get all of the files from the given directory recursively.

array
directories(string|null $directory = null, bool $recursive = false)

Get all of the directories within a given directory.

array
allDirectories(string|null $directory = null)

Get all of the directories within a given directory recursively.

bool
makeDirectory(string $path)

Create a directory.

bool
deleteDirectory(string $directory)

Recursively delete a directory.

never
getDriver()

Reject access to the borrowed Flysystem driver.

never
getAdapter()

Reject access to the borrowed Flysystem adapter.

never
getClient()

Reject access to a borrowed client.

mixed
withDriver(Closure $callback)

Run a callback with borrow-scoped access to the Flysystem driver.

mixed
withAdapter(Closure $callback)

Run a callback with borrow-scoped access to the Flysystem adapter.

mixed
withClient(Closure $callback)

Run a callback with borrow-scoped access to the driver client.

array
getConfig()

Get the disk configuration.

void
serveUsing(Closure|null $callback)

Define a custom callback that generates file download responses.

void
buildTemporaryUrlsUsing(Closure|null $callback)

Define a custom temporary URL builder callback.

void
buildTemporaryUploadUrlsUsing(Closure|null $callback)

Define a custom temporary upload URL builder callback.

mixed
invoke(string $method, array $parameters)

Invoke a synchronous method against a per-operation stack.

mixed
leasedStream(Closure $operation)

Open a stream that owns its client lease until closure.

mixed
withBorrowedAccessor(string $accessor, Closure $callback)

Run a callback with an accessor result from a per-operation stack.

StreamedResponse
buildFileResponse(Request $request, string $path, string|null $name, array $headers, string $disposition)

Build a file response using short borrows and a leased stream.

borrowedInternalsException()

Create the exception used for every rejected borrowed-internal accessor.

never
__call(string $method, array $parameters)

Reject methods that have not been audited for deferred results.

__construct(PoolDefinition $definition, Closure $clientFactory, Closure $stackFactory, Factory $pools, array $config, Closure|null $releaseCallback = null)

Create a client-pooled filesystem.

getDefinition()

Get the pooled client's definition.

string
getPoolName()

Get the pooled client's identity.

bool
invalidatePool()

Remove and close the current client pool.

mixed
withStack(Closure $operation)

Run an operation against a stack built around a borrowed client.

mixed
withBorrowed(Closure $operation)

Run an operation against a stack and its borrowed client.

array
leaseStack()

Borrow a client and build its per-operation adapter stack.

buildStack(object $client)

Build a disk stack and apply every proxy-held callback.

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.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

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.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

InteractsWithPooledFilesystem assertExists(array|string $path, string|null $content = null)

Assert that the given file or directory exists.

Parameters

array|string $path
string|null $content

Return Value

InteractsWithPooledFilesystem

InteractsWithPooledFilesystem assertCount(string $path, int $count, bool $recursive = false)

Assert that the number of files in path equals the expected count.

Parameters

string $path
int $count
bool $recursive

Return Value

InteractsWithPooledFilesystem

InteractsWithPooledFilesystem assertMissing(array|string $path)

Assert that the given file or directory does not exist.

Parameters

array|string $path

Return Value

InteractsWithPooledFilesystem

InteractsWithPooledFilesystem assertDirectoryEmpty(string $path)

Assert that the given directory is empty.

Parameters

string $path

Return Value

InteractsWithPooledFilesystem

InteractsWithPooledFilesystem assertEmpty()

Assert that the disk contains no files.

bool exists(string $path)

Determine if a file or directory exists.

Parameters

string $path

Return Value

bool

bool missing(string $path)

Determine if a file or directory is missing.

Parameters

string $path

Return Value

bool

bool fileExists(string $path)

Determine if a file exists.

Parameters

string $path

Return Value

bool

bool fileMissing(string $path)

Determine if a file is missing.

Parameters

string $path

Return Value

bool

bool directoryExists(string $path)

Determine if a directory exists.

Parameters

string $path

Return Value

bool

bool directoryMissing(string $path)

Determine if a directory is missing.

Parameters

string $path

Return Value

bool

string path(string $path)

Get the full path to the file that exists at the given relative path.

Parameters

string $path

Return Value

string

bool has(string $location)

Determine if a file or directory exists using the Flysystem operator.

Parameters

string $location

Return Value

bool

string read(string $location)

Read a file using the Flysystem operator.

Parameters

string $location

Return Value

string

int fileSize(string $path)

Get a file size using the Flysystem operator.

Parameters

string $path

Return Value

int

string visibility(string $path)

Get raw Flysystem visibility for a path.

Parameters

string $path

Return Value

string

void write(string $location, string $contents, array $config = [])

Write a file using the Flysystem operator.

Parameters

string $location
string $contents
array $config

Return Value

void

void createDirectory(string $location, array $config = [])

Create a directory using the Flysystem operator.

Parameters

string $location
array $config

Return Value

void

string|null get(string $path)

Get the contents of a file.

Parameters

string $path

Return Value

string|null

array|bool|float|int|string|null json(string $path, int $flags = 0)

Get the contents of a file as decoded JSON.

Parameters

string $path
int $flags

Return Value

array|bool|float|int|string|null

StreamedResponse response(string $path, string|null $name = null, array $headers = [], string $disposition = 'inline')

Create a streamed response for a given file.

Parameters

string $path
string|null $name
array $headers
string $disposition

Return Value

StreamedResponse

Response serve(Request $request, string $path, string|null $name = null, array $headers = [])

Create a streamed response for serving a given file.

Parameters

Request $request
string $path
string|null $name
array $headers

Return Value

Response

StreamedResponse download(string $path, string|null $name = null, array $headers = [])

Create a streamed download response for a given file.

Parameters

string $path
string|null $name
array $headers

Return Value

StreamedResponse

bool|string put(string $path, mixed $contents, mixed $options = [])

Write the contents of a file.

Parameters

string $path
mixed $contents
mixed $options

Return Value

bool|string

false|string putFile(string|File|UploadedFile $path, array|string|File|UploadedFile|null $file = null, mixed $options = [])

Store the uploaded file on the disk.

Parameters

string|File|UploadedFile $path
array|string|File|UploadedFile|null $file
mixed $options

Return Value

false|string

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.

Parameters

string|File|UploadedFile $path
array|string|File|UploadedFile|null $file
array|string|null $name
mixed $options

Return Value

false|string

string getVisibility(string $path)

Get the visibility for the given path.

Parameters

string $path

Return Value

string

bool setVisibility(string $path, string $visibility)

Set the visibility for the given path.

Parameters

string $path
string $visibility

Return Value

bool

bool prepend(string $path, string $data, string $separator = PHP_EOL)

Prepend to a file.

Parameters

string $path
string $data
string $separator

Return Value

bool

bool append(string $path, string $data, string $separator = PHP_EOL)

Append to a file.

Parameters

string $path
string $data
string $separator

Return Value

bool

bool delete(array|string $paths)

Delete the file at a given path.

Parameters

array|string $paths

Return Value

bool

bool copy(string $from, string $to)

Copy a file to a new location.

Parameters

string $from
string $to

Return Value

bool

bool move(string $from, string $to)

Move a file to a new location.

Parameters

string $from
string $to

Return Value

bool

int size(string $path)

Get the file size of a given file.

Parameters

string $path

Return Value

int

false|string checksum(string $path, array $options = [])

Get the checksum for a file.

Parameters

string $path
array $options

Return Value

false|string

false|string mimeType(string $path)

Get the mime-type of a given file.

Parameters

string $path

Return Value

false|string

int lastModified(string $path)

Get the file's last modification time.

Parameters

string $path

Return Value

int

mixed readStream(string $path)

Get a resource to read the file.

Parameters

string $path

Return Value

mixed

the leased resource or null on failure

mixed readStreamRange(string $path, int|null $start, int|null $end)

Get a resource to read the partial file.

Parameters

string $path
int|null $start
int|null $end

Return Value

mixed

the leased resource or null on failure

bool writeStream(string $path, mixed $resource, array $options = [])

Write a new file using a stream.

Parameters

string $path
mixed $resource
array $options

Return Value

bool

string url(string $path)

Get the URL for the file at the given path.

Parameters

string $path

Return Value

string

bool providesTemporaryUrls()

Determine if temporary URLs can be generated.

Return Value

bool

bool providesTemporaryUploadUrls()

Determine if temporary upload URLs can be generated.

Return Value

bool

string temporaryUrl(string $path, DateTimeInterface $expiration, array $options = [])

Get a temporary URL for the file at the given path.

Parameters

string $path
DateTimeInterface $expiration
array $options

Return Value

string

array|string temporaryUploadUrl(string $path, DateTimeInterface $expiration, array $options = [])

Get a temporary upload URL for the file at the given path.

Parameters

string $path
DateTimeInterface $expiration
array $options

Return Value

array|string

array files(string|null $directory = null, bool $recursive = false)

Get an array of all files in a directory.

Parameters

string|null $directory
bool $recursive

Return Value

array

array allFiles(string|null $directory = null)

Get all of the files from the given directory recursively.

Parameters

string|null $directory

Return Value

array

array directories(string|null $directory = null, bool $recursive = false)

Get all of the directories within a given directory.

Parameters

string|null $directory
bool $recursive

Return Value

array

array allDirectories(string|null $directory = null)

Get all of the directories within a given directory recursively.

Parameters

string|null $directory

Return Value

array

bool makeDirectory(string $path)

Create a directory.

Parameters

string $path

Return Value

bool

bool deleteDirectory(string $directory)

Recursively delete a directory.

Parameters

string $directory

Return Value

bool

never getDriver()

Reject access to the borrowed Flysystem driver.

Return Value

never

never getAdapter()

Reject access to the borrowed Flysystem adapter.

Return Value

never

never getClient()

Reject access to a borrowed client.

Return Value

never

mixed withDriver(Closure $callback)

Run a callback with borrow-scoped access to the Flysystem driver.

Parameters

Closure $callback

Return Value

mixed

mixed withAdapter(Closure $callback)

Run a callback with borrow-scoped access to the Flysystem adapter.

Parameters

Closure $callback

Return Value

mixed

mixed withClient(Closure $callback)

Run a callback with borrow-scoped access to the driver client.

Parameters

Closure $callback

Return Value

mixed

array getConfig()

Get the disk configuration.

Nested objects remain shared references; the configuration is not deep-copied.

Return Value

array

void serveUsing(Closure|null $callback)

Define a custom callback that generates file download responses.

Boot-only. The callback persists on the manager-cached disk for the worker lifetime and is written to every borrowed adapter.

Parameters

Closure|null $callback

Return Value

void

void buildTemporaryUrlsUsing(Closure|null $callback)

Define a custom temporary URL builder callback.

Boot-only. The callback persists on the manager-cached disk for the worker lifetime and is written to every borrowed adapter.

Parameters

Closure|null $callback

Return Value

void

void buildTemporaryUploadUrlsUsing(Closure|null $callback)

Define a custom temporary upload URL builder callback.

Boot-only. The callback persists on the manager-cached disk for the worker lifetime and is written to every borrowed adapter.

Parameters

Closure|null $callback

Return Value

void

at line 65
protected mixed invoke(string $method, array $parameters)

Invoke a synchronous method against a per-operation stack.

Parameters

string $method
array $parameters

Return Value

mixed

at line 167
protected mixed leasedStream(Closure $operation)

Open a stream that owns its client lease until closure.

Parameters

Closure $operation

Return Value

mixed

at line 195
protected mixed withBorrowedAccessor(string $accessor, Closure $callback)

Run a callback with an accessor result from a per-operation stack.

Parameters

string $accessor
Closure $callback

Return Value

mixed

protected StreamedResponse buildFileResponse(Request $request, string $path, string|null $name, array $headers, string $disposition)

Build a file response using short borrows and a leased stream.

Parameters

Request $request
string $path
string|null $name
array $headers
string $disposition

Return Value

StreamedResponse

protected RuntimeException borrowedInternalsException()

Create the exception used for every rejected borrowed-internal accessor.

Return Value

RuntimeException

never __call(string $method, array $parameters)

Reject methods that have not been audited for deferred results.

Parameters

string $method
array $parameters

Return Value

never

at line 28
__construct(PoolDefinition $definition, Closure $clientFactory, Closure $stackFactory, Factory $pools, array $config, Closure|null $releaseCallback = null)

Create a client-pooled filesystem.

Parameters

PoolDefinition $definition
Closure $clientFactory
Closure $stackFactory
Factory $pools
array $config
Closure|null $releaseCallback

at line 41
PoolDefinition getDefinition()

Get the pooled client's definition.

Return Value

PoolDefinition

at line 49
string getPoolName()

Get the pooled client's identity.

Return Value

string

at line 57
bool invalidatePool()

Remove and close the current client pool.

Return Value

bool

at line 77
protected mixed withStack(Closure $operation)

Run an operation against a stack built around a borrowed client.

Parameters

Closure $operation

Return Value

mixed

at line 89
protected mixed withBorrowed(Closure $operation)

Run an operation against a stack and its borrowed client.

Parameters

Closure $operation

Return Value

mixed

at line 115
protected array leaseStack()

Borrow a client and build its per-operation adapter stack.

Return Value

array

at line 136
protected FilesystemAdapter buildStack(object $client)

Build a disk stack and apply every proxy-held callback.

Parameters

object $client

Return Value

FilesystemAdapter