Documentation

S3Client extends AbstractClient
in package

Client to interact with Amazon Simple Storage Service

Tags
link

User guide

link

API docs

Table of Contents

Constants

COMMAND_PARAMS  = 'command.params'
CURL_OPTIONS  = 'curl.options'
DEFAULT_SELECT_TIMEOUT  = 1.0
DISABLE_REDIRECTS  = \Guzzle\Http\RedirectPlugin::DISABLE
LATEST_API_VERSION  = '2006-03-01'
MAX_HANDLES  = 3
REQUEST_OPTIONS  = 'request.options'
REQUEST_PARAMS  = 'request.params'
SSL_CERT_AUTHORITY  = 'ssl.certificate_authority'

Properties

$aggregator  : DuplicateAggregator
$commandAliases  : array<string|int, mixed>
$commandFactory  : FactoryInterface
$credentials  : CredentialsInterface
$defaultHeaders  : Collection
$directory  : mixed
$eventDispatcher  : EventDispatcherInterface
$inflector  : InflectorInterface
$requestFactory  : RequestFactoryInterface
$resourceIteratorFactory  : ResourceIteratorFactoryInterface
$serviceDescription  : ServiceDescriptionInterface
$signature  : SignatureInterface
$userAgent  : string
$waiterFactory  : WaiterFactoryInterface
$baseUrl  : Url
$config  : Collection
$curlMulti  : CurlMultiInterface
$uriTemplate  : UriTemplateInterface

Methods

__call()  : mixed
Magic method used to retrieve a command
__construct()  : mixed
abortMultipartUpload()  : Model
addSubscriber()  : self
Add an event subscriber to the dispatcher
clearBucket()  : int
Helper used to clear the contents of a bucket. Use the {@see ClearBucket} object directly for more advanced options and control.
completeMultipartUpload()  : Model
copyObject()  : Model
createBucket()  : Model
createMultipartUpload()  : Model
createPresignedUrl()  : string
Create a pre-signed URL for a request
createRequest()  : RequestInterface
Ensures that the duplicate query string aggregator is used so that query string values are sent over the wire as foo=bar&foo=baz.
delete()  : EntityEnclosingRequestInterface
Create a DELETE request for the client
deleteBucket()  : Model
deleteBucketCors()  : Model
deleteBucketLifecycle()  : Model
deleteBucketPolicy()  : Model
deleteBucketReplication()  : Model
deleteBucketTagging()  : Model
deleteBucketWebsite()  : Model
deleteMatchingObjects()  : int
Deletes objects from Amazon S3 that match the result of a ListObjects operation. For example, this allows you to do things like delete all objects that match a specific key prefix.
deleteObject()  : Model
deleteObjects()  : Model
dispatch()  : Event
Helper to dispatch Guzzle events and set the event name on the event
doesBucketExist()  : bool
Determines whether or not a bucket exists by name
doesBucketPolicyExist()  : bool
Determines whether or not a bucket policy exists for a bucket
doesObjectExist()  : bool
Determines whether or not an object exists by name
downloadBucket()  : mixed
Downloads a bucket to the local filesystem
enableMagicMethods()  : mixed
encodeKey()  : string
Raw URL encode a key and allow for '/' characters
execute()  : mixed
Execute one or more commands
explodeKey()  : array<string|int, mixed>
Explode a prefixed key into an array of values
extractPharCacert()  : string
Copies the phar cacert from a phar into the temp directory.
factory()  : S3Client
Factory method to create a new Amazon S3 client using an array of configuration options.
get()  : RequestInterface
Create a GET request for the client
getAllEvents()  : array<string|int, mixed>
Get a list of all of the events emitted from the class
getApiVersion()  : string
Get the API version of the client (e.g. 2006-03-01)
getBaseUrl()  : string|null
Get the client's base URL as either an expanded or raw URI template
getBucketAcl()  : Model
getBucketCors()  : Model
getBucketLifecycle()  : Model
getBucketLifecycleConfiguration()  : Model
getBucketLocation()  : Model
getBucketLogging()  : Model
getBucketNotification()  : Model
getBucketNotificationConfiguration()  : Model
getBucketPolicy()  : Model
getBucketReplication()  : Model
getBucketRequestPayment()  : Model
getBucketTagging()  : Model
getBucketVersioning()  : Model
getBucketWebsite()  : Model
getCommand()  : CommandInterface
Get a command by name. First, the client will see if it has a service description and if the service description defines a command by the supplied name. If no dynamic command is found, the client will look for a concrete command class exists matching the name supplied. If neither are found, an InvalidArgumentException is thrown.
getConfig()  : mixed|Collection
Get a configuration setting or all of the configuration settings. The Collection result of this method can be modified to change the configuration settings of a client.
getCredentials()  : CredentialsInterface
Returns the AWS credentials associated with the client
getCurlMulti()  : CurlMultiInterface|CurlMultiProxy
getDefaultHeaders()  : mixed
getDefaultOption()  : mixed|null
Retrieve a default request option from the client
getDefaultUserAgent()  : string
Get the default User-Agent string to use with Guzzle
getDescription()  : ServiceDescriptionInterface|null
Get the service description of the client
getEndpoint()  : mixed
Get an endpoint for a specific region from a service description
getEventDispatcher()  : EventDispatcherInterface
Get the EventDispatcher of the request
getInflector()  : self
Get the inflector used with the client
getIterator()  : ResourceIteratorInterface
Get a resource iterator from the client.
getListBucketsIterator()  : ResourceIteratorInterface
getListMultipartUploadsIterator()  : ResourceIteratorInterface
getListObjectsIterator()  : ResourceIteratorInterface
getListObjectVersionsIterator()  : ResourceIteratorInterface
getListPartsIterator()  : ResourceIteratorInterface
getObject()  : Model
getObjectAcl()  : Model
getObjectTorrent()  : Model
getObjectUrl()  : string
Returns the URL to an object identified by its bucket and key. If an expiration time is provided, the URL will be signed and set to expire at the provided time.
getRegion()  : string
Get the name of the region to which the client is configured to send requests
getRegions()  : array<string|int, mixed>
Get a list of available regions and region data
getSignature()  : SignatureInterface
Returns the signature implementation used with the client
getSignature()  : S3SignatureInterface
Returns the signature implementation used with the client
getWaiter()  : WaiterInterface
Get a named waiter object
getWaiterFactory()  : WaiterFactoryInterface
Get the waiter factory being used by the client
head()  : RequestInterface
Create a HEAD request for the client
headBucket()  : Model
headObject()  : Model
isValidBucketName()  : bool
Determine if a string is a valid name for a DNS compatible Amazon S3 bucket, meaning the bucket can be used as a subdomain in a URL (e.g., "<bucket>.s3.amazonaws.com").
listBuckets()  : Model
listMultipartUploads()  : Model
listObjects()  : Model
listObjectVersions()  : Model
listParts()  : Model
options()  : RequestInterface
Create an OPTIONS request for the client
patch()  : EntityEnclosingRequestInterface
Create a PATCH request for the client
post()  : EntityEnclosingRequestInterface
Create a POST request for the client
preparePharCacert()  : mixed
put()  : EntityEnclosingRequestInterface
Create a PUT request for the client
putBucketAcl()  : Model
putBucketCors()  : Model
putBucketLifecycle()  : Model
putBucketLifecycleConfiguration()  : Model
putBucketLogging()  : Model
putBucketNotification()  : Model
putBucketNotificationConfiguration()  : Model
putBucketPolicy()  : Model
putBucketReplication()  : Model
putBucketRequestPayment()  : Model
putBucketTagging()  : Model
putBucketVersioning()  : Model
putBucketWebsite()  : Model
putObject()  : Model
putObjectAcl()  : Model
registerStreamWrapper()  : $this
Register the Amazon S3 stream wrapper and associates it with this client object
restoreObject()  : Model
send()  : Response|array<string|int, mixed>
Sends a single request or an array of requests in parallel
setBaseUrl()  : self
Set the base URL of the client
setCommandFactory()  : self
Set the command factory used to create commands by name
setConfig()  : self
Set the configuration object to use with the client
setCredentials()  : self
Sets the credentials object associated with the client
setCurlMulti()  : self
Set a curl multi object to be used internally by the client for transferring requests.
setDefaultHeaders()  : mixed
setDefaultOption()  : $this
Set a default request option on the client that will be used as a default for each request
setDescription()  : ClientInterface
Set the service description of the client
setEventDispatcher()  : self
Set the EventDispatcher of the request
setInflector()  : self
Set the inflector used with the client
setRegion()  : self
Change the region to which the client is configured to send requests
setRequestFactory()  : mixed
setResourceIteratorFactory()  : self
Set the resource iterator factory associated with the client
setSslVerification()  : self
Set SSL verification options.
setUriTemplate()  : self
Set the URI template expander to use with the client
setUserAgent()  : self
Set the User-Agent header to be used on all requests from the client
setWaiterFactory()  : self
Set the waiter factory to use with the client
upload()  : Model
Upload a file, stream, or string to a bucket. If the upload size exceeds the specified threshold, the upload will be performed using parallel multipart uploads.
uploadDirectory()  : mixed
Recursively uploads all files in a given directory to a given bucket.
uploadPart()  : Model
uploadPartCopy()  : Model
waitUntil()  : self
Wait until a resource is available or an associated waiter returns true
waitUntilBucketExists()  : void
waitUntilBucketNotExists()  : void
waitUntilObjectExists()  : void
checkExistenceWithCommand()  : bool
Determines whether or not a resource exists using a command
executeMultiple()  : array<string|int, mixed>
Execute multiple commands in parallel
expandTemplate()  : string
Expand a URI template while merging client config settings into the template variables
getCommandFactory()  : FactoryInterface
Get the command factory associated with the client
getResourceIteratorFactory()  : mixed
getUriTemplate()  : UriTemplateInterface
Get the URI template expander used by the client
initSsl()  : mixed
Initializes SSL settings
prepareCommand()  : RequestInterface
Prepare a command for sending and get the RequestInterface object created by the command
prepareRequest()  : RequestInterface
Prepare a request to be sent from the Client by adding client specific behaviors and properties to the request.
sendMultiple()  : array<string|int, mixed>
Send multiple requests in parallel
createBackoffPlugin()  : BackoffPlugin
Create an Amazon S3 specific backoff plugin
createSignature()  : SignatureInterface
Create an appropriate signature based on the configuration settings

Constants

COMMAND_PARAMS

public mixed COMMAND_PARAMS = 'command.params'

CURL_OPTIONS

public mixed CURL_OPTIONS = 'curl.options'

DEFAULT_SELECT_TIMEOUT

public mixed DEFAULT_SELECT_TIMEOUT = 1.0

DISABLE_REDIRECTS

public mixed DISABLE_REDIRECTS = \Guzzle\Http\RedirectPlugin::DISABLE

LATEST_API_VERSION

public mixed LATEST_API_VERSION = '2006-03-01'

MAX_HANDLES

public mixed MAX_HANDLES = 3

REQUEST_OPTIONS

public mixed REQUEST_OPTIONS = 'request.options'

REQUEST_PARAMS

Use [request.options][params]

public mixed REQUEST_PARAMS = 'request.params'

SSL_CERT_AUTHORITY

public mixed SSL_CERT_AUTHORITY = 'ssl.certificate_authority'

Properties

$commandAliases

protected static array<string|int, mixed> $commandAliases = array( // REST API Docs Aliases 'GetService' => 'ListBuckets', 'GetBucket' => 'ListObjects', 'PutBucket' => 'CreateBucket', // SDK 1.x Aliases 'GetBucketHeaders' => 'HeadBucket', 'GetObjectHeaders' => 'HeadObject', 'SetBucketAcl' => 'PutBucketAcl', 'CreateObject' => 'PutObject', 'DeleteObjects' => 'DeleteMultipleObjects', 'PutObjectCopy' => 'CopyObject', 'SetObjectAcl' => 'PutObjectAcl', 'GetLogs' => 'GetBucketLogging', 'GetVersioningStatus' => 'GetBucketVersioning', 'SetBucketPolicy' => 'PutBucketPolicy', 'CreateBucketNotification' => 'PutBucketNotification', 'GetBucketNotifications' => 'GetBucketNotification', 'CopyPart' => 'UploadPartCopy', 'CreateWebsiteConfig' => 'PutBucketWebsite', 'GetWebsiteConfig' => 'GetBucketWebsite', 'DeleteWebsiteConfig' => 'DeleteBucketWebsite', 'CreateObjectExpirationConfig' => 'PutBucketLifecycle', 'GetObjectExpirationConfig' => 'GetBucketLifecycle', 'DeleteObjectExpirationConfig' => 'DeleteBucketLifecycle', )

Aliases for S3 operations

$defaultHeaders

protected Collection $defaultHeaders

Default HTTP headers to set on each request

$directory

protected mixed $directory = __DIR__

$userAgent

protected string $userAgent

The user agent string to set on each request

$baseUrl

private Url $baseUrl

Base URL of the client

Methods

__call()

Magic method used to retrieve a command

public __call(mixed $method, mixed $args) : mixed
Parameters
$method : mixed

Name of the command object to instantiate

$args : mixed

Arguments to pass to the command

Return values
mixed

Returns the result of the command

abortMultipartUpload()

public abortMultipartUpload([array<string|int, mixed> $args = = '[]' ]) : Model

S3 AbortMultipartUpload

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

clearBucket()

Helper used to clear the contents of a bucket. Use the {@see ClearBucket} object directly for more advanced options and control.

public clearBucket(string $bucket) : int
Parameters
$bucket : string

Name of the bucket to clear.

Return values
int

Returns the number of deleted keys

completeMultipartUpload()

public completeMultipartUpload([array<string|int, mixed> $args = = '[]' ]) : Model

S3 CompleteMultipartUpload

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

copyObject()

public copyObject([array<string|int, mixed> $args = = '[]' ]) : Model

S3 CopyObject

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

createBucket()

public createBucket([array<string|int, mixed> $args = = '[]' ]) : Model

S3 CreateBucket

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

createMultipartUpload()

public createMultipartUpload([array<string|int, mixed> $args = = '[]' ]) : Model

S3 CreateMultipartUpload

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

createPresignedUrl()

Create a pre-signed URL for a request

public createPresignedUrl(RequestInterface $request, int|string|DateTime $expires) : string
Parameters
$request : RequestInterface

Request to generate the URL for. Use the factory methods of the client to create this request object

$expires : int|string|DateTime

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

Tags
throws
InvalidArgumentException

if the request is not associated with this client object

Return values
string

createRequest()

Ensures that the duplicate query string aggregator is used so that query string values are sent over the wire as foo=bar&foo=baz.

public createRequest([mixed $method = 'GET' ][, mixed $uri = null ][, mixed $headers = null ][, mixed $body = null ][, array<string|int, mixed> $options = array() ]) : RequestInterface
Parameters
$method : mixed = 'GET'

HTTP method. Defaults to GET

$uri : mixed = null

Resource URI.

$headers : mixed = null

HTTP headers

$body : mixed = null

Entity body of request (POST/PUT) or response (GET)

$options : array<string|int, mixed> = array()

Array of options to apply to the request

Return values
RequestInterface

delete()

Create a DELETE request for the client

public delete([mixed $uri = null ][, mixed $headers = null ][, mixed $body = null ][, array<string|int, mixed> $options = array() ]) : EntityEnclosingRequestInterface
Parameters
$uri : mixed = null

Resource URI

$headers : mixed = null

HTTP headers

$body : mixed = null

Body to send in the request

$options : array<string|int, mixed> = array()

Options to apply to the request

Return values
EntityEnclosingRequestInterface

deleteBucket()

public deleteBucket([array<string|int, mixed> $args = = '[]' ]) : Model

S3 DeleteBucket

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

deleteBucketCors()

public deleteBucketCors([array<string|int, mixed> $args = = '[]' ]) : Model

S3 DeleteBucketCors

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

deleteBucketLifecycle()

public deleteBucketLifecycle([array<string|int, mixed> $args = = '[]' ]) : Model

S3 DeleteBucketLifecycle

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

deleteBucketPolicy()

public deleteBucketPolicy([array<string|int, mixed> $args = = '[]' ]) : Model

S3 DeleteBucketPolicy

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

deleteBucketReplication()

public deleteBucketReplication([array<string|int, mixed> $args = = '[]' ]) : Model

S3 DeleteBucketReplication

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

deleteBucketTagging()

public deleteBucketTagging([array<string|int, mixed> $args = = '[]' ]) : Model

S3 DeleteBucketTagging

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

deleteBucketWebsite()

public deleteBucketWebsite([array<string|int, mixed> $args = = '[]' ]) : Model

S3 DeleteBucketWebsite

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

deleteMatchingObjects()

Deletes objects from Amazon S3 that match the result of a ListObjects operation. For example, this allows you to do things like delete all objects that match a specific key prefix.

public deleteMatchingObjects(string $bucket[, string $prefix = '' ][, string $regex = '' ][, array<string|int, mixed> $options = array() ]) : int
Parameters
$bucket : string

Bucket that contains the object keys

$prefix : string = ''

Optionally delete only objects under this key prefix

$regex : string = ''

Delete only objects that match this regex

$options : array<string|int, mixed> = array()

Options used when deleting the object:

  • before_delete: Callback to invoke before each delete. The callback will receive a Guzzle\Common\Event object with context.
Tags
see
S3Client::listObjects
see
ClearBucket

For more options or customization

throws
RuntimeException

if no prefix and no regex is given

Return values
int

Returns the number of deleted keys

deleteObject()

public deleteObject([array<string|int, mixed> $args = = '[]' ]) : Model

S3 DeleteObject

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

deleteObjects()

public deleteObjects([array<string|int, mixed> $args = = '[]' ]) : Model

S3 DeleteObjects

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

dispatch()

Helper to dispatch Guzzle events and set the event name on the event

public dispatch(mixed $eventName[, array<string|int, mixed> $context = array() ]) : Event
Parameters
$eventName : mixed

Name of the event to dispatch

$context : array<string|int, mixed> = array()

Context of the event

Return values
Event

Returns the created event object

doesBucketExist()

Determines whether or not a bucket exists by name

public doesBucketExist(string $bucket[, bool $accept403 = true ][, array<string|int, mixed> $options = array() ]) : bool
Parameters
$bucket : string

The name of the bucket

$accept403 : bool = true

Set to true if 403s are acceptable

$options : array<string|int, mixed> = array()

Additional options to add to the executed command

Return values
bool

doesBucketPolicyExist()

Determines whether or not a bucket policy exists for a bucket

public doesBucketPolicyExist(string $bucket[, array<string|int, mixed> $options = array() ]) : bool
Parameters
$bucket : string

The name of the bucket

$options : array<string|int, mixed> = array()

Additional options to add to the executed command

Return values
bool

doesObjectExist()

Determines whether or not an object exists by name

public doesObjectExist(string $bucket, string $key[, array<string|int, mixed> $options = array() ]) : bool
Parameters
$bucket : string

The name of the bucket

$key : string

The key of the object

$options : array<string|int, mixed> = array()

Additional options to add to the executed command

Return values
bool

downloadBucket()

Downloads a bucket to the local filesystem

public downloadBucket(string $directory, string $bucket[, string $keyPrefix = '' ][, array<string|int, mixed> $options = array() ]) : mixed
Parameters
$directory : string

Directory to download to

$bucket : string

Bucket to download from

$keyPrefix : string = ''

Only download objects that use this key prefix

$options : array<string|int, mixed> = array()

Associative array of download options

  • params: Array of parameters to use with each GetObject operation performed during the transfer
  • base_dir: Base directory to remove from each object key when storing in the local filesystem
  • force: Set to true to download every file, even if the file is already on the local filesystem and has not changed
  • concurrency: Maximum number of parallel downloads (defaults to 10)
  • debug: Set to true or a fopen resource to enable debug mode to print information about each download
  • allow_resumable: Set to true to allow previously interrupted downloads to be resumed using a Range GET

enableMagicMethods()

public enableMagicMethods(mixed $isEnabled) : mixed
Parameters
$isEnabled : mixed
Tags
codeCoverageIgnore

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()

Execute one or more commands

public execute(mixed $command) : mixed
Parameters
$command : mixed

Command, array of commands or Traversable object containing commands to execute

Return values
mixed

Returns the result of the executed command or an array of commands if executing multiple commands

explodeKey()

Explode a prefixed key into an array of values

public static explodeKey(string $key) : array<string|int, mixed>
Parameters
$key : string

Key to explode

Return values
array<string|int, mixed>

Returns the exploded

extractPharCacert()

Copies the phar cacert from a phar into the temp directory.

public static extractPharCacert(string $pharCacertPath) : string
Parameters
$pharCacertPath : string

Path to the phar cacert. For example: 'phar://aws.phar/Guzzle/Http/Resources/cacert.pem'

Tags
throws
RuntimeException

Throws if the phar cacert cannot be found or the file cannot be copied to the temp dir.

Return values
string

Returns the path to the extracted cacert file.

get()

Create a GET request for the client

public get([mixed $uri = null ][, mixed $headers = null ][, mixed $options = array() ]) : RequestInterface
Parameters
$uri : mixed = null

Resource URI

$headers : mixed = null

HTTP headers

$options : mixed = array()

Options to apply to the request. For BC compatibility, you can also pass a string to tell Guzzle to download the body of the response to a particular location. Use the 'body' option instead for forward compatibility.

Return values
RequestInterface

getAllEvents()

Get a list of all of the events emitted from the class

public static getAllEvents() : array<string|int, mixed>
Return values
array<string|int, mixed>

getApiVersion()

Get the API version of the client (e.g. 2006-03-01)

public getApiVersion() : string
Return values
string

getBaseUrl()

Get the client's base URL as either an expanded or raw URI template

public getBaseUrl([mixed $expand = true ]) : string|null
Parameters
$expand : mixed = true

Set to FALSE to get the raw base URL without URI template expansion

Return values
string|null

getBucketAcl()

public getBucketAcl([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetBucketAcl

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getBucketCors()

public getBucketCors([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetBucketCors

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getBucketLifecycle()

public getBucketLifecycle([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetBucketLifecycle

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getBucketLifecycleConfiguration()

public getBucketLifecycleConfiguration([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetBucketLifecycleConfiguration

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getBucketLocation()

public getBucketLocation([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetBucketLocation

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getBucketLogging()

public getBucketLogging([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetBucketLogging

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getBucketNotification()

public getBucketNotification([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetBucketNotification

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getBucketNotificationConfiguration()

public getBucketNotificationConfiguration([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetBucketNotificationConfiguration

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getBucketPolicy()

public getBucketPolicy([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetBucketPolicy

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getBucketReplication()

public getBucketReplication([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetBucketReplication

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getBucketRequestPayment()

public getBucketRequestPayment([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetBucketRequestPayment

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getBucketTagging()

public getBucketTagging([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetBucketTagging

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getBucketVersioning()

public getBucketVersioning([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetBucketVersioning

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getBucketWebsite()

public getBucketWebsite([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetBucketWebsite

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getCommand()

Get a command by name. First, the client will see if it has a service description and if the service description defines a command by the supplied name. If no dynamic command is found, the client will look for a concrete command class exists matching the name supplied. If neither are found, an InvalidArgumentException is thrown.

public getCommand(mixed $name[, array<string|int, mixed> $args = array() ]) : CommandInterface
Parameters
$name : mixed

Name of the command to retrieve

$args : array<string|int, mixed> = array()

Arguments to pass to the command

Return values
CommandInterface

getConfig()

Get a configuration setting or all of the configuration settings. The Collection result of this method can be modified to change the configuration settings of a client.

public final getConfig([mixed $key = false ]) : mixed|Collection

A client should honor the following special values:

  • request.options: Associative array of default RequestFactory options to apply to each request
  • request.params: Associative array of request parameters (data values) to apply to each request
  • curl.options: Associative array of cURL configuration settings to apply to each request
  • ssl.certificate_authority: Path a CAINFO, CAPATH, true to use strict defaults, or false to disable verification
  • redirect.disable: Set to true to disable redirects
Parameters
$key : mixed = false

Configuration value to retrieve. Set to FALSE to retrieve all values of the client. The object return can be modified, and modifications will affect the client's config.

Return values
mixed|Collection

getDefaultHeaders()

public getDefaultHeaders() : mixed

getDefaultOption()

Retrieve a default request option from the client

public getDefaultOption(string $keyOrPath) : mixed|null
Parameters
$keyOrPath : string

request.options key (e.g. allow_redirects) or path to a nested key (e.g. headers/foo)

Return values
mixed|null

getDefaultUserAgent()

Get the default User-Agent string to use with Guzzle

public getDefaultUserAgent() : string
Return values
string

getEndpoint()

Get an endpoint for a specific region from a service description

public static getEndpoint(ServiceDescriptionInterface $description, mixed $region, mixed $scheme) : mixed

This function will no longer be updated to work with new regions.

Parameters
$description : ServiceDescriptionInterface
$region : mixed
$scheme : mixed

getInflector()

Get the inflector used with the client

public getInflector() : self
Return values
self

getIterator()

Get a resource iterator from the client.

public getIterator(mixed $command[, array<string|int, mixed> $commandOptions = null ][, array<string|int, mixed> $iteratorOptions = array() ]) : ResourceIteratorInterface
Parameters
$command : mixed

Command class or command name.

$commandOptions : array<string|int, mixed> = null

Command options used when creating commands.

$iteratorOptions : array<string|int, mixed> = array()

Iterator options passed to the iterator when it is instantiated.

Return values
ResourceIteratorInterface

getListMultipartUploadsIterator()

public getListMultipartUploadsIterator([array<string|int, mixed> $args = = '[]' ]) : ResourceIteratorInterface

The input array uses the parameters of the ListMultipartUploads operation

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
ResourceIteratorInterface

getListObjectVersionsIterator()

public getListObjectVersionsIterator([array<string|int, mixed> $args = = '[]' ]) : ResourceIteratorInterface

The input array uses the parameters of the ListObjectVersions operation

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
ResourceIteratorInterface

getObject()

public getObject([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetObject

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getObjectAcl()

public getObjectAcl([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetObjectAcl

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getObjectTorrent()

public getObjectTorrent([array<string|int, mixed> $args = = '[]' ]) : Model

S3 GetObjectTorrent

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

getObjectUrl()

Returns the URL to an object identified by its bucket and key. If an expiration time is provided, the URL will be signed and set to expire at the provided time.

public getObjectUrl(string $bucket, string $key[, mixed $expires = null ][, array<string|int, mixed> $args = array() ]) : string

Note: This method does not ensure that the generated URL is valid. For example, the bucket referenced may not exist, the key referenced may not exist, and the URL might include parameters that require it to be signed. If you need to use parameters that require a signed URL (e.g., ResponseCacheControl), then you must sign the URL either by providing an $expires argument or by signing the URL returned by this method in some other manner.

Parameters
$bucket : string

The name of the bucket where the object is located

$key : string

The key of the object

$expires : mixed = null

The time at which the URL should expire

$args : array<string|int, mixed> = array()

Arguments to the GetObject command. Additionally you can specify a "Scheme" if you would like the URL to use a different scheme than what the client is configured to use

Return values
string

The URL to the object

getRegion()

Get the name of the region to which the client is configured to send requests

public getRegion() : string
Return values
string

getRegions()

Get a list of available regions and region data

public getRegions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getWaiter()

Get a named waiter object

public getWaiter(mixed $waiter[, array<string|int, mixed> $input = array() ]) : WaiterInterface
Parameters
$waiter : mixed

Name of the waiter

$input : array<string|int, mixed> = array()

Values used as input for the underlying operation and to control the waiter

Return values
WaiterInterface

head()

Create a HEAD request for the client

public head([mixed $uri = null ][, mixed $headers = null ][, array<string|int, mixed> $options = array() ]) : RequestInterface
Parameters
$uri : mixed = null

Resource URI

$headers : mixed = null

HTTP headers

$options : array<string|int, mixed> = array()

Options to apply to the request

Return values
RequestInterface

headBucket()

public headBucket([array<string|int, mixed> $args = = '[]' ]) : Model

S3 HeadBucket

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

headObject()

public headObject([array<string|int, mixed> $args = = '[]' ]) : Model

S3 HeadObject

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

isValidBucketName()

Determine if a string is a valid name for a DNS compatible Amazon S3 bucket, meaning the bucket can be used as a subdomain in a URL (e.g., "<bucket>.s3.amazonaws.com").

public static isValidBucketName(string $bucket) : bool
Parameters
$bucket : string

The name of the bucket to check.

Return values
bool

TRUE if the bucket name is valid or FALSE if it is invalid.

listBuckets()

public listBuckets([array<string|int, mixed> $args = = '[]' ]) : Model

S3 ListBuckets

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

listMultipartUploads()

public listMultipartUploads([array<string|int, mixed> $args = = '[]' ]) : Model

S3 ListMultipartUploads

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

listObjects()

public listObjects([array<string|int, mixed> $args = = '[]' ]) : Model

S3 ListObjects

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

listObjectVersions()

public listObjectVersions([array<string|int, mixed> $args = = '[]' ]) : Model

S3 ListObjectVersions

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

listParts()

public listParts([array<string|int, mixed> $args = = '[]' ]) : Model

S3 ListParts

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

options()

Create an OPTIONS request for the client

public options([mixed $uri = null ][, array<string|int, mixed> $options = array() ]) : RequestInterface
Parameters
$uri : mixed = null

Resource URI

$options : array<string|int, mixed> = array()

Options to apply to the request

Return values
RequestInterface

patch()

Create a PATCH request for the client

public patch([mixed $uri = null ][, mixed $headers = null ][, mixed $body = null ][, array<string|int, mixed> $options = array() ]) : EntityEnclosingRequestInterface
Parameters
$uri : mixed = null

Resource URI

$headers : mixed = null

HTTP headers

$body : mixed = null

Body to send in the request

$options : array<string|int, mixed> = array()

Options to apply to the request

Return values
EntityEnclosingRequestInterface

post()

Create a POST request for the client

public post([mixed $uri = null ][, mixed $headers = null ][, mixed $postBody = null ][, array<string|int, mixed> $options = array() ]) : EntityEnclosingRequestInterface
Parameters
$uri : mixed = null

Resource URI

$headers : mixed = null

HTTP headers

$postBody : mixed = null

POST body. Can be a string, EntityBody, or associative array of POST fields to send in the body of the request. Prefix a value in the array with the @ symbol to reference a file.

$options : array<string|int, mixed> = array()

Options to apply to the request

Return values
EntityEnclosingRequestInterface

preparePharCacert()

public preparePharCacert([mixed $md5Check = true ]) : mixed
Parameters
$md5Check : mixed = true

put()

Create a PUT request for the client

public put([mixed $uri = null ][, mixed $headers = null ][, mixed $body = null ][, array<string|int, mixed> $options = array() ]) : EntityEnclosingRequestInterface
Parameters
$uri : mixed = null

Resource URI

$headers : mixed = null

HTTP headers

$body : mixed = null

Body to send in the request

$options : array<string|int, mixed> = array()

Options to apply to the request

Return values
EntityEnclosingRequestInterface

putBucketAcl()

public putBucketAcl([array<string|int, mixed> $args = = '[]' ]) : Model

S3 PutBucketAcl

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

putBucketCors()

public putBucketCors([array<string|int, mixed> $args = = '[]' ]) : Model

S3 PutBucketCors

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

putBucketLifecycle()

public putBucketLifecycle([array<string|int, mixed> $args = = '[]' ]) : Model

S3 PutBucketLifecycle

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

putBucketLifecycleConfiguration()

public putBucketLifecycleConfiguration([array<string|int, mixed> $args = = '[]' ]) : Model

S3 PutBucketLifecycleConfiguration

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

putBucketLogging()

public putBucketLogging([array<string|int, mixed> $args = = '[]' ]) : Model

S3 PutBucketLogging

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

putBucketNotification()

public putBucketNotification([array<string|int, mixed> $args = = '[]' ]) : Model

S3 PutBucketNotification

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

putBucketNotificationConfiguration()

public putBucketNotificationConfiguration([array<string|int, mixed> $args = = '[]' ]) : Model

S3 PutBucketNotificationConfiguration

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

putBucketPolicy()

public putBucketPolicy([array<string|int, mixed> $args = = '[]' ]) : Model

S3 PutBucketPolicy

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

putBucketReplication()

public putBucketReplication([array<string|int, mixed> $args = = '[]' ]) : Model

S3 PutBucketReplication

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

putBucketRequestPayment()

public putBucketRequestPayment([array<string|int, mixed> $args = = '[]' ]) : Model

S3 PutBucketRequestPayment

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

putBucketTagging()

public putBucketTagging([array<string|int, mixed> $args = = '[]' ]) : Model

S3 PutBucketTagging

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

putBucketVersioning()

public putBucketVersioning([array<string|int, mixed> $args = = '[]' ]) : Model

S3 PutBucketVersioning

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

putBucketWebsite()

public putBucketWebsite([array<string|int, mixed> $args = = '[]' ]) : Model

S3 PutBucketWebsite

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

putObject()

public putObject([array<string|int, mixed> $args = = '[]' ]) : Model

S3 PutObject

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

putObjectAcl()

public putObjectAcl([array<string|int, mixed> $args = = '[]' ]) : Model

S3 PutObjectAcl

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

registerStreamWrapper()

Register the Amazon S3 stream wrapper and associates it with this client object

public registerStreamWrapper() : $this
Return values
$this

restoreObject()

public restoreObject([array<string|int, mixed> $args = = '[]' ]) : Model

S3 RestoreObject

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

send()

Sends a single request or an array of requests in parallel

public send(mixed $requests) : Response|array<string|int, mixed>
Parameters
$requests : mixed

One or more RequestInterface objects to send

Tags
throws
TransferException
Return values
Response|array<string|int, mixed>

Returns a single Response or an array of Response objects

setBaseUrl()

Set the base URL of the client

public setBaseUrl(mixed $url) : self
Parameters
$url : mixed

The base service endpoint URL of the webservice

Return values
self

setCommandFactory()

Set the command factory used to create commands by name

public setCommandFactory(FactoryInterface $factory) : self
Parameters
$factory : FactoryInterface

Command factory

Return values
self

setConfig()

Set the configuration object to use with the client

public final setConfig(mixed $config) : self
Parameters
$config : mixed

Parameters that define how the client behaves

Return values
self

setCurlMulti()

Set a curl multi object to be used internally by the client for transferring requests.

public setCurlMulti(CurlMultiInterface $curlMulti) : self
Parameters
$curlMulti : CurlMultiInterface

Multi object

Return values
self

setDefaultHeaders()

public setDefaultHeaders(mixed $headers) : mixed
Parameters
$headers : mixed

setDefaultOption()

Set a default request option on the client that will be used as a default for each request

public setDefaultOption(string $keyOrPath, mixed $value) : $this
Parameters
$keyOrPath : string

request.options key (e.g. allow_redirects) or path to a nested key (e.g. headers/foo)

$value : mixed

Value to set

Return values
$this

setRegion()

Change the region to which the client is configured to send requests

public setRegion(mixed $region) : self
Parameters
$region : mixed

Name of the region

Return values
self

setSslVerification()

Set SSL verification options.

public final setSslVerification([mixed $certificateAuthority = true ][, mixed $verifyPeer = true ][, mixed $verifyHost = 2 ]) : self

Setting $certificateAuthority to TRUE will result in the bundled cacert.pem being used to verify against the remote host.

Alternate certificates to verify against can be specified with the $certificateAuthority option set to the full path to a certificate file, or the path to a directory containing certificates.

Setting $certificateAuthority to FALSE will turn off peer verification, unset the bundled cacert.pem, and disable host verification. Please don't do this unless you really know what you're doing, and why you're doing it.

Parameters
$certificateAuthority : mixed = true

bool, file path, or directory path

$verifyPeer : mixed = true

FALSE to stop from verifying the peer's certificate.

$verifyHost : mixed = 2

Set to 1 to check the existence of a common name in the SSL peer certificate. 2 to check the existence of a common name and also verify that it matches the hostname provided.

Return values
self

setUserAgent()

Set the User-Agent header to be used on all requests from the client

public setUserAgent(mixed $userAgent[, mixed $includeDefault = false ]) : self
Parameters
$userAgent : mixed

User agent string

$includeDefault : mixed = false

Set to true to prepend the value to Guzzle's default user agent string

Return values
self

upload()

Upload a file, stream, or string to a bucket. If the upload size exceeds the specified threshold, the upload will be performed using parallel multipart uploads.

public upload(string $bucket, string $key, mixed $body[, string $acl = 'private' ][, array<string|int, mixed> $options = array() ]) : Model
Parameters
$bucket : string

Bucket to upload the object

$key : string

Key of the object

$body : mixed

Object data to upload. Can be a Guzzle\Http\EntityBodyInterface, stream resource, or string of data to upload.

$acl : string = 'private'

ACL to apply to the object

$options : array<string|int, mixed> = array()

Custom options used when executing commands:

  • params: Custom parameters to use with the upload. The parameters must map to a PutObject or InitiateMultipartUpload operation parameters.
  • min_part_size: Minimum size to allow for each uploaded part when performing a multipart upload.
  • concurrency: Maximum number of concurrent multipart uploads.
  • before_upload: Callback to invoke before each multipart upload. The callback will receive a Guzzle\Common\Event object with context.
Tags
see
UploadBuilder

for more options and customization

Return values
Model

Returns the modeled result of the performed operation

uploadDirectory()

Recursively uploads all files in a given directory to a given bucket.

public uploadDirectory(string $directory, string $bucket[, string $keyPrefix = null ][, array<string|int, mixed> $options = array() ]) : mixed
Parameters
$directory : string

Full path to a directory to upload

$bucket : string

Name of the bucket

$keyPrefix : string = null

Virtual directory key prefix to add to each upload

$options : array<string|int, mixed> = array()

Associative array of upload options

  • params: Array of parameters to use with each PutObject operation performed during the transfer
  • base_dir: Base directory to remove from each object key
  • force: Set to true to upload every file, even if the file is already in Amazon S3 and has not changed
  • concurrency: Maximum number of parallel uploads (defaults to 10)
  • debug: Set to true or an fopen resource to enable debug mode to print information about each upload
  • multipart_upload_size: When the size of a file exceeds this value, the file will be uploaded using a multipart upload.
Tags
see
S3Sync

for more options and customization

uploadPart()

public uploadPart([array<string|int, mixed> $args = = '[]' ]) : Model

S3 UploadPart

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

uploadPartCopy()

public uploadPartCopy([array<string|int, mixed> $args = = '[]' ]) : Model

S3 UploadPartCopy

Parameters
$args : array<string|int, mixed> = = '[]'
Return values
Model

waitUntil()

Wait until a resource is available or an associated waiter returns true

public waitUntil(mixed $waiter[, array<string|int, mixed> $input = array() ]) : self
Parameters
$waiter : mixed

Name of the waiter

$input : array<string|int, mixed> = array()

Values used as input for the underlying operation and to control the waiter

Return values
self

waitUntilBucketExists()

public waitUntilBucketExists(array<string|int, mixed> $input) : void

The input array uses the parameters of the HeadBucket operation and waiter specific settings

Parameters
$input : array<string|int, mixed>

waitUntilBucketNotExists()

public waitUntilBucketNotExists(array<string|int, mixed> $input) : void

The input array uses the parameters of the HeadBucket operation and waiter specific settings

Parameters
$input : array<string|int, mixed>

waitUntilObjectExists()

public waitUntilObjectExists(array<string|int, mixed> $input) : void

The input array uses the parameters of the HeadObject operation and waiter specific settings

Parameters
$input : array<string|int, mixed>

checkExistenceWithCommand()

Determines whether or not a resource exists using a command

protected checkExistenceWithCommand(CommandInterface $command[, bool $accept403 = false ]) : bool
Parameters
$command : CommandInterface

Command used to poll for the resource

$accept403 : bool = false

Set to true if 403s are acceptable

Tags
throws
S3Exception|Exception

if there is an unhandled exception

Return values
bool

executeMultiple()

Execute multiple commands in parallel

protected executeMultiple(array<string|int, mixed>|Traversable $commands) : array<string|int, mixed>
Parameters
$commands : array<string|int, mixed>|Traversable

Array of CommandInterface objects to execute

Tags
throws
CommandTransferException
Return values
array<string|int, mixed>

Returns an array of the executed commands

expandTemplate()

Expand a URI template while merging client config settings into the template variables

protected expandTemplate(string $template[, array<string|int, mixed> $variables = null ]) : string
Parameters
$template : string

Template to expand

$variables : array<string|int, mixed> = null

Variables to inject

Return values
string

getResourceIteratorFactory()

protected getResourceIteratorFactory() : mixed

initSsl()

Initializes SSL settings

protected initSsl() : mixed

prepareRequest()

Prepare a request to be sent from the Client by adding client specific behaviors and properties to the request.

protected prepareRequest(RequestInterface $request[, array<string|int, mixed> $options = array() ]) : RequestInterface
Parameters
$request : RequestInterface

Request to prepare for the client

$options : array<string|int, mixed> = array()

Options to apply to the request

Return values
RequestInterface

sendMultiple()

Send multiple requests in parallel

protected sendMultiple(array<string|int, mixed> $requests) : array<string|int, mixed>
Parameters
$requests : array<string|int, mixed>

Array of RequestInterface objects

Return values
array<string|int, mixed>

Returns an array of Response objects


        
On this page

Search results