class SentryS3V3Adapter extends AwsS3V3Adapter implements DecoratedFilesystem, InvalidatesPool

Traits

Decorates the underlying filesystem by wrapping all calls to it with tracing.

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 S3Client $client

The AWS S3 client.

from  AwsS3V3Adapter
protected Filesystem $filesystem from  FilesystemDecorator
protected array $defaultData from  FilesystemDecorator
protected bool $recordSpans from  FilesystemDecorator
protected bool $recordBreadcrumbs from  FilesystemDecorator

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.

bool
copyToDisk(Filesystem|string|UnitEnum $disk, string $from, string|null $to = null)

Copy a file to another disk.

bool
moveToDisk(Filesystem|string|UnitEnum $disk, string $from, string|null $to = null)

Move a file to another disk.

bool
transferFile(Filesystem $source, string $from, Filesystem $destination, string $to)

Transfer a file without holding a source lease during the destination write.

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

__construct(AwsS3V3Adapter $filesystem, array $defaultData, bool $recordSpans, bool $recordBreadcrumbs)

Create a new Sentry S3 filesystem adapter.

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 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.

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.

image(string $path)

Create an image instance from a file in storage.

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

Build a file response using the supplied request context.

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 part of the file.

array
normalizeStreamRange(int|null $start, int|null $end)

Normalize and validate byte-range stream arguments.

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.

string
getFtpUrl(string $path)

Get the URL for the file at the given path.

string
getLocalUrl(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.

string
encodeUrlPath(string $path)

Encode a path for use in a URL.

string
concatPathToUrl(string $url, string $path)

Encode and concatenate a path to a URL.

UriInterface
replaceBaseUrl(UriInterface $uri, string $url)

Replace the scheme, host and port of the given UriInterface with values from the given URL.

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 recursively.

bool
makeDirectory(string $path)

Create a directory.

bool
deleteDirectory(string $directory)

Recursively delete a directory.

FilesystemOperator
getDriver()

Get the Flysystem driver.

FilesystemAdapter
getAdapter()

Get the Flysystem adapter.

array
getConfig()

Get the configuration values.

string|null
parseVisibility(string|null $visibility)

Parse the given visibility value.

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.

Closure|null
prepareTemporaryUrlCallback(Closure|null $callback)

Prepare a temporary URL callback for direct invocation.

bool
throwsExceptions()

Determine if Flysystem exceptions should be thrown.

void
report(Throwable $exception)

Report the exception.

bool
shouldReport()

Determine if Flysystem exceptions should be reported.

static void
flushState()

Flush all static state.

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

Open a whole-object or ranged stream without applying the disk's failure policy.

S3Client
getClient()

Get the underlying S3 client.

mixed
withSentry(string $method, array $args, string|null $description, array $data)

Execute the method on the underlying filesystem and wrap it with tracing and log a breadcrumb.

bool
transferToDisk(string $method, Filesystem|string|UnitEnum $disk, string $from, string|null $to)

Trace a transfer while preserving the wrapped disk's identity check.

getFilesystem()

Get the wrapped filesystem.

bool
invalidatePool()

Invalidate the wrapped filesystem's pool when supported.

array
getDescriptionAndDataForPathOrPaths(array|string $pathOrPaths)

Get the description and data for one or more paths.

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

in TransfersFiles at line 21
bool copyToDisk(Filesystem|string|UnitEnum $disk, string $from, string|null $to = null)

Copy a file to another disk.

Parameters

Filesystem|string|UnitEnum $disk
string $from
string|null $to

Return Value

bool

in TransfersFiles at line 33
bool moveToDisk(Filesystem|string|UnitEnum $disk, string $from, string|null $to = null)

Move a file to another disk.

Parameters

Filesystem|string|UnitEnum $disk
string $from
string|null $to

Return Value

bool

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.

Parameters

Filesystem $source
string $from
Filesystem $destination
string $to

Return Value

bool

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.

Parameters

string $name
callable|object $macro

Return Value

void

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.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 57
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

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.

Return Value

void

in Macroable at line 78
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 103
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 19
__construct(AwsS3V3Adapter $filesystem, array $defaultData, bool $recordSpans, bool $recordBreadcrumbs)

Create a new Sentry S3 filesystem adapter.

Parameters

AwsS3V3Adapter $filesystem
array $defaultData
bool $recordSpans
bool $recordBreadcrumbs

FilesystemAdapterDecorator 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

FilesystemAdapterDecorator

in FilesystemAdapter at line 151
FilesystemAdapter 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

FilesystemAdapter

FilesystemAdapterDecorator assertMissing(array|string $path)

Assert that the given file or directory does not exist.

Parameters

array|string $path

Return Value

FilesystemAdapterDecorator

FilesystemAdapterDecorator assertDirectoryEmpty(string $path)

Assert that the given directory is empty.

Parameters

string $path

Return Value

FilesystemAdapterDecorator

in FilesystemAdapter at line 201
FilesystemAdapter assertEmpty()

Assert that the disk contains no files.

Return Value

FilesystemAdapter

bool exists(string $path)

Determine if a file exists.

Parameters

string $path

Return Value

bool

in FilesystemAdapter at line 219
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

in FilesystemAdapter at line 235
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

in FilesystemAdapter at line 251
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

string|null get(string $path)

Get the contents of a file.

Parameters

string $path

Return Value

string|null

in FilesystemAdapter at line 285
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

in FilesystemAdapter at line 297
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

Exceptions

UnableToRetrieveMetadata

in FilesystemAdapter at line 317
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

Exceptions

UnableToRetrieveMetadata

in FilesystemAdapter at line 329
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

Exceptions

UnableToRetrieveMetadata

in FilesystemAdapter at line 337
Image image(string $path)

Create an image instance from a file in storage.

Parameters

string $path

Return Value

Image

in FilesystemAdapter 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.

Parameters

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

Return Value

StreamedResponse

in FilesystemDecorator at line 126
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

in FilesystemDecorator at line 136
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

in FilesystemDecorator at line 149
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

in FilesystemDecorator at line 173
string getVisibility(string $path)

Get the visibility for the given path.

Parameters

string $path

Return Value

string

in FilesystemDecorator at line 181
bool setVisibility(string $path, string $visibility)

Set the visibility for the given path.

Parameters

string $path
string $visibility

Return Value

bool

in FilesystemDecorator at line 189
bool prepend(string $path, string $data, string $separator = PHP_EOL)

Prepend to a file.

Parameters

string $path
string $data
string $separator

Return Value

bool

in FilesystemDecorator at line 199
bool append(string $path, string $data, string $separator = PHP_EOL)

Append to a file.

Parameters

string $path
string $data
string $separator

Return Value

bool

in FilesystemDecorator at line 209
bool delete(array|string $paths)

Delete the file at a given path.

Parameters

array|string $paths

Return Value

bool

in FilesystemDecorator at line 219
bool copy(string $from, string $to)

Copy a file to a new location.

Parameters

string $from
string $to

Return Value

bool

in FilesystemDecorator at line 227
bool move(string $from, string $to)

Move a file to a new location.

Parameters

string $from
string $to

Return Value

bool

in FilesystemDecorator at line 273
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

in FilesystemDecorator at line 281
int lastModified(string $path)

Get the file's last modification time.

Parameters

string $path

Return Value

int

in FilesystemDecorator at line 106
mixed readStream(string $path)

Get a resource to read the file.

Parameters

string $path

Return Value

mixed

in FilesystemDecorator at line 116
mixed readStreamRange(string $path, int|null $start, int|null $end)

Get a resource to read part of the file.

Parameters

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

Return Value

mixed

in FilesystemAdapter at line 766
protected array normalizeStreamRange(int|null $start, int|null $end)

Normalize and validate byte-range stream arguments.

Parameters

int|null $start
int|null $end

Return Value

array

in FilesystemDecorator at line 165
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

in FilesystemAdapter at line 836
protected string getFtpUrl(string $path)

Get the URL for the file at the given path.

Parameters

string $path

Return Value

string

in FilesystemAdapter at line 846
protected string getLocalUrl(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

in FilesystemAdapter at line 930
protected string encodeUrlPath(string $path)

Encode a path for use in a URL.

Parameters

string $path

Return Value

string

in FilesystemAdapter at line 938
protected string concatPathToUrl(string $url, string $path)

Encode and concatenate a path to a URL.

Parameters

string $url
string $path

Return Value

string

in FilesystemAdapter 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.

Parameters

UriInterface $uri
string $url

Return Value

UriInterface

in FilesystemDecorator at line 289
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

in FilesystemDecorator at line 297
array allFiles(string|null $directory = null)

Get all of the files from the given directory recursively.

Parameters

string|null $directory

Return Value

array

in FilesystemDecorator at line 305
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

in FilesystemDecorator at line 313
array allDirectories(string|null $directory = null)

Get all of the directories recursively.

Parameters

string|null $directory

Return Value

array

in FilesystemDecorator at line 321
bool makeDirectory(string $path)

Create a directory.

Parameters

string $path

Return Value

bool

in FilesystemDecorator at line 329
bool deleteDirectory(string $directory)

Recursively delete a directory.

Parameters

string $directory

Return Value

bool

in FilesystemAdapter at line 1054
FilesystemOperator getDriver()

Get the Flysystem driver.

Return Value

FilesystemOperator

in FilesystemAdapter at line 1062
FilesystemAdapter getAdapter()

Get the Flysystem adapter.

Return Value

FilesystemAdapter

in FilesystemAdapter at line 1070
array getConfig()

Get the configuration values.

Return Value

array

in FilesystemAdapter at line 1080
protected string|null parseVisibility(string|null $visibility)

Parse the given visibility value.

Parameters

string|null $visibility

Return Value

string|null

Exceptions

InvalidArgumentException

in FilesystemAdapter 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.

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 cached disk adapter for the worker lifetime and runs on every subsequent temporary URL generation for that disk.

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 cached disk adapter for the worker lifetime and runs on every subsequent temporary upload URL generation for that disk.

Parameters

Closure|null $callback

Return Value

void

in FilesystemAdapter at line 1131
protected Closure|null prepareTemporaryUrlCallback(Closure|null $callback)

Prepare a temporary URL callback for direct invocation.

Parameters

Closure|null $callback

Return Value

Closure|null

in FilesystemAdapter at line 1150
protected bool throwsExceptions()

Determine if Flysystem exceptions should be thrown.

Return Value

bool

in FilesystemAdapter at line 1160
protected void report(Throwable $exception)

Report the exception.

Parameters

Throwable $exception

Return Value

void

Exceptions

Throwable

in FilesystemAdapter at line 1170
protected bool shouldReport()

Determine if Flysystem exceptions should be reported.

Return Value

bool

in FilesystemAdapter at line 1178
static void flushState()

Flush all static state.

Return Value

void

at line 38
mixed readStreamRangeOrFail(string $path, int|null $start = null, int|null $end = null)

Open a whole-object or ranged stream without applying the disk's failure policy.

Parameters

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

Return Value

mixed

in AwsS3V3Adapter at line 227
S3Client getClient()

Get the underlying S3 client.

Return Value

S3Client

protected mixed withSentry(string $method, array $args, string|null $description, array $data)

Execute the method on the underlying filesystem and wrap it with tracing and log a breadcrumb.

Parameters

string $method
array $args
string|null $description
array $data

Return Value

mixed

in FilesystemDecorator at line 251
protected bool transferToDisk(string $method, Filesystem|string|UnitEnum $disk, string $from, string|null $to)

Trace a transfer while preserving the wrapped disk's identity check.

Parameters

string $method
Filesystem|string|UnitEnum $disk
string $from
string|null $to

Return Value

bool

in FilesystemDecorator at line 337
Filesystem getFilesystem()

Get the wrapped filesystem.

Return Value

Filesystem

in FilesystemDecorator at line 345
bool invalidatePool()

Invalidate the wrapped filesystem's pool when supported.

Return Value

bool

in FilesystemDecorator at line 356
protected array getDescriptionAndDataForPathOrPaths(array|string $pathOrPaths)

Get the description and data for one or more paths.

Parameters

array|string $pathOrPaths

Return Value

array