S3Client
extends AwsClient
in package
implements
S3ClientInterface
Uses
S3ClientTrait
Client used to interact with Amazon Simple Storage Service (Amazon S3).
Supported API Versions
This class uses a service description model that is associated at
runtime based on the version
option given when constructing the
client. The version
option will determine which API operations,
waiters, and paginators are available for a client. Creating a command or a
specific API operation can be done using magic methods (e.g.,
$client->commandName(/** parameters */)
, or using the
$client->getCommand
method of the client.
- AbortMultipartUpload
- CompleteMultipartUpload
- CopyObject
- CreateBucket
- CreateBucketMetadataTableConfiguration
- CreateMultipartUpload
- CreateSession
- DeleteBucket
- DeleteBucketAnalyticsConfiguration
- DeleteBucketCors
- DeleteBucketEncryption
- DeleteBucketIntelligentTieringConfiguration
- DeleteBucketInventoryConfiguration
- DeleteBucketLifecycle
- DeleteBucketMetadataTableConfiguration
- DeleteBucketMetricsConfiguration
- DeleteBucketOwnershipControls
- DeleteBucketPolicy
- DeleteBucketReplication
- DeleteBucketTagging
- DeleteBucketWebsite
- DeleteObject
- DeleteObjectTagging
- DeleteObjects
- DeletePublicAccessBlock
- GetBucketAccelerateConfiguration
- GetBucketAcl
- GetBucketAnalyticsConfiguration
- GetBucketCors
- GetBucketEncryption
- GetBucketIntelligentTieringConfiguration
- GetBucketInventoryConfiguration
- GetBucketLifecycle
- GetBucketLifecycleConfiguration
- GetBucketLocation
- GetBucketLogging
- GetBucketMetadataTableConfiguration
- GetBucketMetricsConfiguration
- GetBucketNotification
- GetBucketNotificationConfiguration
- GetBucketOwnershipControls
- GetBucketPolicy
- GetBucketPolicyStatus
- GetBucketReplication
- GetBucketRequestPayment
- GetBucketTagging
- GetBucketVersioning
- GetBucketWebsite
- GetObject
- GetObjectAcl
- GetObjectAttributes
- GetObjectLegalHold
- GetObjectLockConfiguration
- GetObjectRetention
- GetObjectTagging
- GetObjectTorrent
- GetPublicAccessBlock
- HeadBucket
- HeadObject
- ListBucketAnalyticsConfigurations
- ListBucketIntelligentTieringConfigurations
- ListBucketInventoryConfigurations
- ListBucketMetricsConfigurations
- ListBuckets
- ListDirectoryBuckets
- ListMultipartUploads
- ListObjectVersions
- ListObjects
- ListObjectsV2
- ListParts
- PutBucketAccelerateConfiguration
- PutBucketAcl
- PutBucketAnalyticsConfiguration
- PutBucketCors
- PutBucketEncryption
- PutBucketIntelligentTieringConfiguration
- PutBucketInventoryConfiguration
- PutBucketLifecycle
- PutBucketLifecycleConfiguration
- PutBucketLogging
- PutBucketMetricsConfiguration
- PutBucketNotification
- PutBucketNotificationConfiguration
- PutBucketOwnershipControls
- PutBucketPolicy
- PutBucketReplication
- PutBucketRequestPayment
- PutBucketTagging
- PutBucketVersioning
- PutBucketWebsite
- PutObject
- PutObjectAcl
- PutObjectLegalHold
- PutObjectLockConfiguration
- PutObjectRetention
- PutObjectTagging
- PutPublicAccessBlock
- RestoreObject
- SelectObjectContent
- UploadPart
- UploadPartCopy
- WriteGetObjectResponse
Table of Contents
Interfaces
- S3ClientInterface
- Represents an AWS client.
Methods
- __call() : mixed
- __construct() : mixed
- The client constructor accepts the following options:
- __sleep() : mixed
- _apply_use_arn_region() : mixed
- _default_disable_express_session_auth() : mixed
- _default_s3_express_identity_provider() : mixed
- copy() : mixed
- copyAsync() : mixed
- createPresignedRequest() : RequestInterface
- Create a pre-signed URL for the given S3 command object.
- deleteMatchingObjects() : mixed
- deleteMatchingObjectsAsync() : mixed
- determineBucketRegion() : mixed
- determineBucketRegionAsync() : PromiseInterface
- doesBucketExist() : mixed
- doesBucketExistV2() : mixed
- doesObjectExist() : mixed
- doesObjectExistV2() : mixed
- downloadBucket() : mixed
- downloadBucketAsync() : mixed
- emitDeprecationWarning() : mixed
- encodeKey() : string
- Raw URL encode a key and allow for '/' characters
- execute() : mixed
- executeAsync() : mixed
- factory() : static
- getApi() : Service
- getArguments() : array<string|int, mixed>
- Get an array of client constructor arguments used by the client.
- getClientBuiltIns() : array<string|int, mixed>
- Provides the set of built-in keys and values used for endpoint resolution
- getClientContextParams() : array<string|int, mixed>
- Provides the set of service context parameter key-value pairs used for endpoint resolution.
- getCommand() : CommandInterface
- getConfig() : mixed|null
- Get a client configuration value.
- getCredentials() : PromiseInterface
- Returns a promise that is fulfilled with an {@see \Aws\Credentials\CredentialsInterface} object.
- getEndpoint() : UriInterface
- Gets the default endpoint, or base URL, used by the client.
- getEndpointProvider() : mixed
- getEndpointProviderArgs() : array<string|int, mixed>
- Retrieves arguments to be used in endpoint resolution.
- getHandlerList() : HandlerList
- Get the handler list used to transfer commands.
- getIterator() : mixed
- getObjectUrl() : string
- Returns the URL to an object identified by its bucket and key.
- getPaginator() : mixed
- getRegion() : string
- Get the region to which the client is configured to send requests.
- getSignatureProvider() : callable
- Get the signature_provider function of the client.
- getWaiter() : mixed
- isBucketDnsCompatible() : bool
- Determine if a string is a valid name for a DNS compatible Amazon S3 bucket.
- isDirectoryBucket() : bool
- Determines whether a bucket is a directory bucket.
- registerStreamWrapper() : mixed
- registerStreamWrapperV2() : mixed
- upload() : mixed
- uploadAsync() : mixed
- uploadDirectory() : mixed
- uploadDirectoryAsync() : mixed
- waitUntil() : mixed
Methods
__call()
public
__call(mixed $name, array<string|int, mixed> $args) : mixed
Parameters
- $name : mixed
- $args : array<string|int, mixed>
__construct()
The client constructor accepts the following options:
public
__construct(array<string|int, mixed> $args) : mixed
In addition to the options available to AwsClient::__construct, S3Client accepts the following options:
- bucket_endpoint: (bool) Set to true to send requests to a
hardcoded bucket endpoint rather than create an endpoint as a result
of injecting the bucket into the URL. This option is useful for
interacting with CNAME endpoints. Note: if you are using version 2.243.0
and above and do not expect the bucket name to appear in the host, you will
also need to set
use_path_style_endpoint
totrue
. - calculate_md5: (bool) Set to false to disable calculating an MD5 for all Amazon S3 signed uploads.
- s3_us_east_1_regional_endpoint:
(Aws\S3\RegionalEndpoint\ConfigurationInterface|Aws\CacheInterface|callable|string|array)
Specifies whether to use regional or legacy endpoints for the us-east-1
region. Provide an Aws\S3\RegionalEndpoint\ConfigurationInterface object, an
instance of Aws\CacheInterface, a callable configuration provider used
to create endpoint configuration, a string value of
legacy
orregional
, or an associative array with the following keys: endpoint_types: (string) Set tolegacy
orregional
, defaults tolegacy
- use_accelerate_endpoint: (bool) Set to true to send requests to an S3 Accelerate endpoint by default. Can be enabled or disabled on individual operations by setting '@use_accelerate_endpoint' to true or false. Note: you must enable S3 Accelerate on a bucket before it can be accessed via an Accelerate endpoint.
- use_arn_region: (Aws\S3\UseArnRegion\ConfigurationInterface, Aws\CacheInterface, bool, callable) Set to true to enable the client to use the region from a supplied ARN argument instead of the client's region. Provide an instance of Aws\S3\UseArnRegion\ConfigurationInterface, an instance of Aws\CacheInterface, a callable that provides a promise for a Configuration object, or a boolean value. Defaults to false (i.e. the SDK will not follow the ARN region if it conflicts with the client region and instead throw an error).
- use_dual_stack_endpoint: (bool) Set to true to send requests to an S3 Dual Stack endpoint by default, which enables IPv6 Protocol. Can be enabled or disabled on individual operations by setting '@use_dual_stack_endpoint' to true or false. Note: you cannot use it together with an accelerate endpoint.
- use_path_style_endpoint: (bool) Set to true to send requests to an S3 path style endpoint by default. Can be enabled or disabled on individual operations by setting '@use_path_style_endpoint' to true or false. Note: you cannot use it together with an accelerate endpoint.
- disable_multiregion_access_points: (bool) Set to true to disable sending multi region requests. They are enabled by default. Can be enabled or disabled on individual operations by setting '@disable_multiregion_access_points' to true or false. Note: you cannot use it together with an accelerate or dualstack endpoint.
Parameters
- $args : array<string|int, mixed>
__sleep()
public
__sleep() : mixed
_apply_use_arn_region()
public
static _apply_use_arn_region(mixed $value, array<string|int, mixed> &$args, HandlerList $list) : mixed
Parameters
- $value : mixed
- $args : array<string|int, mixed>
- $list : HandlerList
_default_disable_express_session_auth()
public
static _default_disable_express_session_auth(array<string|int, mixed> &$args) : mixed
Parameters
- $args : array<string|int, mixed>
_default_s3_express_identity_provider()
public
static _default_s3_express_identity_provider(array<string|int, mixed> $args) : mixed
Parameters
- $args : array<string|int, mixed>
copy()
public
copy(mixed $fromB, mixed $fromK, mixed $destB, mixed $destK[, mixed $acl = 'private' ][, array<string|int, mixed> $opts = [] ]) : mixed
Parameters
- $fromB : mixed
- $fromK : mixed
- $destB : mixed
- $destK : mixed
- $acl : mixed = 'private'
- $opts : array<string|int, mixed> = []
Tags
copyAsync()
public
copyAsync(mixed $fromB, mixed $fromK, mixed $destB, mixed $destK[, mixed $acl = 'private' ][, array<string|int, mixed> $opts = [] ]) : mixed
Parameters
- $fromB : mixed
- $fromK : mixed
- $destB : mixed
- $destK : mixed
- $acl : mixed = 'private'
- $opts : array<string|int, mixed> = []
Tags
createPresignedRequest()
Create a pre-signed URL for the given S3 command object.
public
createPresignedRequest(CommandInterface $command, mixed $expires[, array<string|int, mixed> $options = [] ]) : RequestInterface
Parameters
- $command : CommandInterface
-
Command to create a pre-signed URL for.
- $expires : mixed
-
The time at which the URL should expire. This can be a Unix timestamp, a PHP DateTime object, or a string that can be evaluated by strtotime().
- $options : array<string|int, mixed> = []
Return values
RequestInterfacedeleteMatchingObjects()
public
deleteMatchingObjects(mixed $bucket[, mixed $prefix = '' ][, mixed $regex = '' ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $bucket : mixed
- $prefix : mixed = ''
- $regex : mixed = ''
- $options : array<string|int, mixed> = []
Tags
deleteMatchingObjectsAsync()
public
deleteMatchingObjectsAsync(mixed $bucket[, mixed $prefix = '' ][, mixed $regex = '' ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $bucket : mixed
- $prefix : mixed = ''
- $regex : mixed = ''
- $options : array<string|int, mixed> = []
Tags
determineBucketRegion()
public
determineBucketRegion(mixed $bucketName) : mixed
Parameters
- $bucketName : mixed
Tags
determineBucketRegionAsync()
public
determineBucketRegionAsync(string $bucketName) : PromiseInterface
Parameters
- $bucketName : string
Tags
Return values
PromiseInterfacedoesBucketExist()
public
doesBucketExist(mixed $bucket) : mixed
Parameters
- $bucket : mixed
Tags
doesBucketExistV2()
public
doesBucketExistV2(mixed $bucket[, mixed $accept403 = false ]) : mixed
Parameters
- $bucket : mixed
- $accept403 : mixed = false
Tags
doesObjectExist()
public
doesObjectExist(mixed $bucket, mixed $key[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $bucket : mixed
- $key : mixed
- $options : array<string|int, mixed> = []
Tags
doesObjectExistV2()
public
doesObjectExistV2(mixed $bucket, mixed $key[, mixed $includeDeleteMarkers = false ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $bucket : mixed
- $key : mixed
- $includeDeleteMarkers : mixed = false
- $options : array<string|int, mixed> = []
Tags
downloadBucket()
public
downloadBucket(mixed $directory, mixed $bucket[, mixed $keyPrefix = '' ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $directory : mixed
- $bucket : mixed
- $keyPrefix : mixed = ''
- $options : array<string|int, mixed> = []
Tags
downloadBucketAsync()
public
downloadBucketAsync(mixed $directory, mixed $bucket[, mixed $keyPrefix = '' ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $directory : mixed
- $bucket : mixed
- $keyPrefix : mixed = ''
- $options : array<string|int, mixed> = []
Tags
emitDeprecationWarning()
public
static emitDeprecationWarning() : mixed
encodeKey()
Raw URL encode a key and allow for '/' characters
public
static encodeKey(string $key) : string
Parameters
- $key : string
-
Key to encode
Return values
string —Returns the encoded key
execute()
public
execute(CommandInterface $command) : mixed
Parameters
- $command : CommandInterface
executeAsync()
public
executeAsync(CommandInterface $command) : mixed
Parameters
- $command : CommandInterface
factory()
public
static factory([array<string|int, mixed> $config = [] ]) : static
Parameters
- $config : array<string|int, mixed> = []
Tags
Return values
staticgetApi()
public
abstract getApi() : Service
Return values
ServicegetArguments()
Get an array of client constructor arguments used by the client.
public
static getArguments() : array<string|int, mixed>
Return values
array<string|int, mixed>getClientBuiltIns()
Provides the set of built-in keys and values used for endpoint resolution
public
getClientBuiltIns() : array<string|int, mixed>
Return values
array<string|int, mixed>getClientContextParams()
Provides the set of service context parameter key-value pairs used for endpoint resolution.
public
getClientContextParams() : array<string|int, mixed>
Return values
array<string|int, mixed>getCommand()
public
abstract getCommand(string $name[, array<string|int, mixed> $args = [] ]) : CommandInterface
Parameters
- $name : string
- $args : array<string|int, mixed> = []
Return values
CommandInterfacegetConfig()
Get a client configuration value.
public
getConfig([mixed $option = null ]) : mixed|null
Parameters
- $option : mixed = null
-
The option to retrieve. Pass null to retrieve all options.
Return values
mixed|nullgetCredentials()
Returns a promise that is fulfilled with an {@see \Aws\Credentials\CredentialsInterface} object.
public
getCredentials() : PromiseInterface
If you need the credentials synchronously, then call the wait() method on the returned promise.
Return values
PromiseInterfacegetEndpoint()
Gets the default endpoint, or base URL, used by the client.
public
getEndpoint() : UriInterface
Return values
UriInterfacegetEndpointProvider()
public
getEndpointProvider() : mixed
getEndpointProviderArgs()
Retrieves arguments to be used in endpoint resolution.
public
getEndpointProviderArgs() : array<string|int, mixed>
Return values
array<string|int, mixed>getHandlerList()
Get the handler list used to transfer commands.
public
getHandlerList() : HandlerList
This list can be modified to add middleware or to change the underlying handler used to send HTTP requests.
Return values
HandlerListgetIterator()
public
getIterator(mixed $name[, array<string|int, mixed> $args = [] ]) : mixed
Parameters
- $name : mixed
- $args : array<string|int, mixed> = []
getObjectUrl()
Returns the URL to an object identified by its bucket and key.
public
getObjectUrl(string $bucket, string $key) : string
The URL returned by this method is not signed nor does it ensure that the bucket and key given to the method exist. If you need a signed URL, then use the S3Client::createPresignedRequest method and get the URI of the signed request.
Parameters
- $bucket : string
-
The name of the bucket where the object is located
- $key : string
-
The key of the object
Return values
string —The URL to the object
getPaginator()
public
getPaginator(mixed $name[, array<string|int, mixed> $args = [] ]) : mixed
Parameters
- $name : mixed
- $args : array<string|int, mixed> = []
getRegion()
Get the region to which the client is configured to send requests.
public
getRegion() : string
Return values
stringgetSignatureProvider()
Get the signature_provider function of the client.
public
final getSignatureProvider() : callable
Return values
callablegetWaiter()
public
getWaiter(mixed $name[, array<string|int, mixed> $args = [] ]) : mixed
Parameters
- $name : mixed
- $args : array<string|int, mixed> = []
isBucketDnsCompatible()
Determine if a string is a valid name for a DNS compatible Amazon S3 bucket.
public
static isBucketDnsCompatible(string $bucket) : bool
DNS compatible bucket names can be used as a subdomain in a URL (e.g.,
"
Parameters
- $bucket : string
-
Bucket name to check.
Return values
boolisDirectoryBucket()
Determines whether a bucket is a directory bucket.
public
static isDirectoryBucket(string $bucket) : bool
Only considers the availability zone/suffix format
Parameters
- $bucket : string
Return values
boolregisterStreamWrapper()
public
registerStreamWrapper() : mixed
Tags
registerStreamWrapperV2()
public
registerStreamWrapperV2() : mixed
Tags
upload()
public
upload(mixed $bucket, mixed $key, mixed $body[, mixed $acl = 'private' ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $bucket : mixed
- $key : mixed
- $body : mixed
- $acl : mixed = 'private'
- $options : array<string|int, mixed> = []
Tags
uploadAsync()
public
uploadAsync(mixed $bucket, mixed $key, mixed $body[, mixed $acl = 'private' ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $bucket : mixed
- $key : mixed
- $body : mixed
- $acl : mixed = 'private'
- $options : array<string|int, mixed> = []
Tags
uploadDirectory()
public
uploadDirectory(mixed $directory, mixed $bucket[, mixed $keyPrefix = null ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $directory : mixed
- $bucket : mixed
- $keyPrefix : mixed = null
- $options : array<string|int, mixed> = []
Tags
uploadDirectoryAsync()
public
uploadDirectoryAsync(mixed $directory, mixed $bucket[, mixed $keyPrefix = null ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $directory : mixed
- $bucket : mixed
- $keyPrefix : mixed = null
- $options : array<string|int, mixed> = []
Tags
waitUntil()
public
waitUntil(mixed $name[, array<string|int, mixed> $args = [] ]) : mixed
Parameters
- $name : mixed
- $args : array<string|int, mixed> = []