Class BatchDelete
- Aws\S3\BatchDelete implements GuzzleHttp\Promise\PromisorInterface
- Namespace: Aws\S3
- Link: http://docs.aws.amazon.com/AmazonS3/latest/API/multiobjectdeleteapi.html
- Located at S3/BatchDelete.php
Efficiently deletes many objects from a single Amazon S3 bucket using an iterator that yields keys. Deletes are made using the DeleteObjects API operation.
$s3 = new Aws\S3\Client([ 'region' => 'us-west-2', 'version' => 'latest' ]); $listObjectsParams = ['Bucket' => 'foo', 'Prefix' => 'starts/with/']; $delete = Aws\S3\BatchDelete::fromListObjects($s3, $listObjectsParams); // Asynchronously delete $promise = $delete->promise(); // Force synchronous completion $delete->delete();
When using one of the batch delete creational static methods, you can supply an associative array of options:
- before: Function invoked before executing a command. The function is passed the command that is about to be executed. This can be useful for logging, adding custom request headers, etc.
- batch_size: The size of each delete batch. Defaults to 1000.
Methods Summary
-
static
fromListObjects ( Aws\AwsClientInterface $client, array $listObjectsParams, array $options = [] )
Creates a BatchDelete object from all of the paginated results of a ListObjects operation. Each result that is returned by the ListObjects operation will be deleted.
-
static
fromIterator ( Aws\AwsClientInterface $client, string $bucket, Iterator $iter, array $options = [] )
Creates a BatchDelete object from an iterator that yields results.
- promise ( )
-
delete ( )
Synchronously deletes all of the objects.
Methods Details
static
Aws\S3\BatchDelete
fromListObjects (
Aws\AwsClientInterface
$client,
array
$listObjectsParams,
array
$options = []
)
Creates a BatchDelete object from all of the paginated results of a ListObjects operation. Each result that is returned by the ListObjects operation will be deleted.
Parameters
Aws\AwsClientInterface |
$client | AWS Client to use. |
array | $listObjectsParams | ListObjects API parameters |
array | $options = [] | BatchDelete options. |
Returns
Aws\S3\BatchDelete |
static
Aws\S3\BatchDelete
fromIterator (
Aws\AwsClientInterface
$client,
string
$bucket,
Iterator
$iter,
array
$options = []
)
Creates a BatchDelete object from an iterator that yields results.
Parameters
Aws\AwsClientInterface |
$client | AWS Client to use to execute commands |
string | $bucket | Bucket where the objects are stored |
Iterator | $iter | Iterator that yields assoc arrays |
array | $options = [] | BatchDelete options |
Returns
Aws\S3\BatchDelete |
GuzzleHttp\Promise\PromiseInterface
promise (
)
delete ( )
Synchronously deletes all of the objects.
Exceptions
Aws\S3\Exception\DeleteMultipleObjectsException on error. |