PHP Interface Webiny\Component\Amazon\S3\S3ClientInterface

Exibir arquivo Open project: Webiny/Framework

Public Methods

Method Description
__construct ( $accessKeyId, $secretAccessKey, $region, $endpoint = null ) Amazon S3 constructor
clearBucket ( string $bucket ) : integer Helper used to clear the contents of a bucket. Use the {@see ClearBucket} object directly for more advanced options and control.
copyObject ( string $sourceBucket, string $sourceKey, string $targetBucket, string $targetKey, array $params = [] ) : mixed Creates a copy of an object that is already stored in Amazon S3.
createBucket ( string $bucket, array $params = [] ) : mixed Creates a new bucket.
deleteBucket ( $bucket ) : mixed Deletes the bucket.
deleteMatchingObjects ( string $bucket, string $prefix = '', string $regex = '', array $options = [] ) : integer 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 ( string $bucket, string $key, array $params = [] ) : mixed Removes the null version (if there is one) of an object and inserts a delete marker, which becomes the latest version of the object.
deleteObjects ( string $bucket, array $objects ) : mixed This operation enables you to delete multiple objects from a bucket using a single HTTP request.
doesBucketExist ( string $bucket, boolean $accept403 = true, array $params = [] ) : boolean Determines whether or not a bucket exists by name
doesObjectExist ( string $bucket, string $key, array $params = [] ) : boolean Determines whether or not an object exists by name
downloadBucket ( string $directory, string $bucket, string $keyPrefix = '', array $options = [] ) Downloads a bucket to the local filesystem
getBucketAcl ( string $bucket ) : mixed Get access control policy for the bucket
getBucketLocation ( string $bucket ) : mixed Returns the region the bucket resides in.
getBucketPolicy ( string $bucket ) : mixed Returns the policy of a specified bucket.
getListBucketsIterator ( ) : mixed Get array of buckets Available keys: Name, CreationDate
getListObjectsIterator ( string $bucket, array $params = [] ) : mixed Get objects iterator
getObject ( string $bucket, string $key, array $params = [] ) : mixed Get object identified by bucket and key
getObjectAcl ( $bucket, $key ) : mixed Returns the access control list (ACL) of an object.
getObjectUrl ( string $bucket, string $key, mixed $expires = null, array $args = [] ) : 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.
listBuckets ( ) : mixed Returns a list of all buckets owned by the authenticated sender of the request.
listObjects ( string $bucket, array $params = [] ) : mixed Returns some or all (up to 1000) of the objects in a bucket.
multipartUpload ( $bucket, $key, $sourcePath, integer $concurrency = 1 ) : mixed In case of large files, use the multipartUpload method, so the file is sent in chunks to S3, without the need to read the complete file in memory.
putBucketAcl ( string $bucket, string $acl ) : mixed Sets the permissions on a bucket using access control lists (ACL).
putObject ( string $bucket, string $key, string $content, array $params = [] ) : mixed Adds an object to a bucket.
putObjectAcl ( string $bucket, string $key, string $acl ) : mixed Set the access control list (ACL) permissions for an object that already exists in a bucket
restoreObject ( string $bucket, string $key, integer $days ) : mixed Restores an archived copy of an object back into Amazon S3
uploadDirectory ( string $directory, string $bucket, string $keyPrefix = null, array $options = [] ) Recursively uploads all files in a given directory to a given bucket.

Method Details

__construct() public method

Amazon S3 constructor
public __construct ( $accessKeyId, $secretAccessKey, $region, $endpoint = null )
$accessKeyId
$secretAccessKey
$region
$endpoint

clearBucket() public method

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 ) : integer
$bucket string Name of the bucket to clear.
return integer Returns the number of deleted keys

copyObject() public method

Creates a copy of an object that is already stored in Amazon S3.
public copyObject ( string $sourceBucket, string $sourceKey, string $targetBucket, string $targetKey, array $params = [] ) : mixed
$sourceBucket string
$sourceKey string
$targetBucket string
$targetKey string
$params array
return mixed

createBucket() public method

Creates a new bucket.
public createBucket ( string $bucket, array $params = [] ) : mixed
$bucket string
$params array
return mixed

deleteBucket() public method

All objects (including all object versions and Delete Markers) in the bucket must be deleted before the bucket itself can be deleted.
public deleteBucket ( $bucket ) : mixed
$bucket
return mixed

deleteMatchingObjects() public method

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.
See also: Aws\S3\S3Client::listObjects
See also: Aws\S3\Model\ClearBucket For more options or customization
public deleteMatchingObjects ( string $bucket, string $prefix = '', string $regex = '', array $options = [] ) : integer
$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 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.
return integer Returns the number of deleted keys

deleteObject() public method

If there isn't a null version, Amazon S3 does not remove any objects.
public deleteObject ( string $bucket, string $key, array $params = [] ) : mixed
$bucket string
$key string
$params array
return mixed

deleteObjects() public method

You may specify up to 1000 keys.
public deleteObjects ( string $bucket, array $objects ) : mixed
$bucket string
$objects array
return mixed

doesBucketExist() public method

Determines whether or not a bucket exists by name
public doesBucketExist ( string $bucket, boolean $accept403 = true, array $params = [] ) : boolean
$bucket string The name of the bucket
$accept403 boolean Set to true if 403s are acceptable
$params array Additional options to add to the executed command
return boolean

doesObjectExist() public method

Determines whether or not an object exists by name
public doesObjectExist ( string $bucket, string $key, array $params = [] ) : boolean
$bucket string The name of the bucket
$key string The key of the object
$params array Additional options to add to the executed command
return boolean

downloadBucket() public method

Downloads a bucket to the local filesystem
public downloadBucket ( string $directory, string $bucket, string $keyPrefix = '', array $options = [] )
$directory string Directory to download to
$bucket string Bucket to download from
$keyPrefix string Only download objects that use this key prefix
$options 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

getBucketAcl() public method

Get access control policy for the bucket
public getBucketAcl ( string $bucket ) : mixed
$bucket string
return mixed

getBucketLocation() public method

Returns the region the bucket resides in.
public getBucketLocation ( string $bucket ) : mixed
$bucket string
return mixed

getBucketPolicy() public method

Returns the policy of a specified bucket.
public getBucketPolicy ( string $bucket ) : mixed
$bucket string
return mixed

getListBucketsIterator() public method

Get array of buckets Available keys: Name, CreationDate
public getListBucketsIterator ( ) : mixed
return mixed

getListObjectsIterator() public method

Get objects iterator
public getListObjectsIterator ( string $bucket, array $params = [] ) : mixed
$bucket string
$params array
return mixed

getObject() public method

Get object identified by bucket and key
public getObject ( string $bucket, string $key, array $params = [] ) : mixed
$bucket string
$key string
$params array
return mixed

getObjectAcl() public method

Returns the access control list (ACL) of an object.
public getObjectAcl ( $bucket, $key ) : mixed
$bucket
$key
return mixed

getObjectUrl() public method

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 $args = [] ) : string
$bucket string The name of the bucket where the object is located
$key string The key of the object
$expires mixed The time at which the URL should expire
$args 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 string The URL to the object

listBuckets() public method

Available keys: Name, CreationDate
public listBuckets ( ) : mixed
return mixed

listObjects() public method

You can use the request parameters as selection criteria to return a subset of the objects in a bucket.
public listObjects ( string $bucket, array $params = [] ) : mixed
$bucket string
$params array
return mixed

multipartUpload() public method

In case of large files, use the multipartUpload method, so the file is sent in chunks to S3, without the need to read the complete file in memory.
public multipartUpload ( $bucket, $key, $sourcePath, integer $concurrency = 1 ) : mixed
$bucket
$key
$sourcePath
$concurrency integer
return mixed

putBucketAcl() public method

Sets the permissions on a bucket using access control lists (ACL).
public putBucketAcl ( string $bucket, string $acl ) : mixed
$bucket string
$acl string private | public-read | public-read-write | authenticated-read
return mixed

putObject() public method

Adds an object to a bucket.
public putObject ( string $bucket, string $key, string $content, array $params = [] ) : mixed
$bucket string
$key string
$content string
$params array
return mixed

putObjectAcl() public method

Set the access control list (ACL) permissions for an object that already exists in a bucket
public putObjectAcl ( string $bucket, string $key, string $acl ) : mixed
$bucket string
$key string
$acl string private | public-read | public-read-write | authenticated-read | bucket-owner-read | bucket-owner-full-control
return mixed

restoreObject() public method

Restores an archived copy of an object back into Amazon S3
public restoreObject ( string $bucket, string $key, integer $days ) : mixed
$bucket string
$key string
$days integer
return mixed

uploadDirectory() public method

Recursively uploads all files in a given directory to a given bucket.
See also: Aws\S3\S3Sync\S3Sync for more options and customization
public uploadDirectory ( string $directory, string $bucket, string $keyPrefix = null, array $options = [] )
$directory string Full path to a directory to upload
$bucket string Name of the bucket
$keyPrefix string Virtual directory key prefix to add to each upload
$options 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.