PHP Class Webiny\Component\Amazon\Bridge\S3\S3

Inheritance: implements S3ClientInterface
Afficher le fichier Open project: Webiny/Framework Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( $accessKeyId, $secretAccessKey, $region, $endpoint = null )
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 ( array $params = [] ) : 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 méthode

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

clearBucket() public méthode

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.
Résultat integer Returns the number of deleted keys

copyObject() public méthode

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
Résultat mixed

createBucket() public méthode

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

deleteBucket() public méthode

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
Résultat mixed

deleteMatchingObjects() public méthode

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.
Résultat integer Returns the number of deleted keys

deleteObject() public méthode

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
Résultat mixed

deleteObjects() public méthode

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

doesBucketExist() public méthode

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
Résultat boolean

doesObjectExist() public méthode

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
Résultat boolean

downloadBucket() public méthode

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 méthode

Get access control policy for the bucket
public getBucketAcl ( string $bucket ) : mixed
$bucket string
Résultat mixed

getBucketLocation() public méthode

Returns the region the bucket resides in.
public getBucketLocation ( string $bucket ) : mixed
$bucket string
Résultat mixed

getBucketPolicy() public méthode

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

getListBucketsIterator() public méthode

Get array of buckets Available keys: Name, CreationDate
public getListBucketsIterator ( array $params = [] ) : mixed
$params array
Résultat mixed

getListObjectsIterator() public méthode

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

getObject() public méthode

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

getObjectAcl() public méthode

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

getObjectUrl() public méthode

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
Résultat string The URL to the object

listBuckets() public méthode

Available keys: Name, CreationDate
public listBuckets ( ) : mixed
Résultat mixed

listObjects() public méthode

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
Résultat mixed

multipartUpload() public méthode

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
Résultat mixed

putBucketAcl() public méthode

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
Résultat mixed

putObject() public méthode

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
Résultat mixed

putObjectAcl() public méthode

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
Résultat mixed

restoreObject() public méthode

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
Résultat mixed

uploadDirectory() public méthode

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.