Class: Aws::S3::Object::Collection

Inherits:
Resources::Collection
  • Object
show all
Defined in:
lib/aws-sdk-s3/object.rb

Batch Actions collapse

Instance Method Details

#batch_delete!(options = {}) ⇒ void

This method returns an undefined value.

Examples:

Request syntax with placeholder values


object.batch_delete!({
  mfa: "MFA",
  request_payer: "requester", # accepts requester
  bypass_governance_retention: false,
  expected_bucket_owner: "AccountId",
})

Parameters:

  • options ({}) (defaults to: {})

Options Hash (options):

  • :mfa (String)

    The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device. Required to permanently delete a versioned object if versioning is configured with MFA delete enabled.

  • :request_payer (String)

    Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see [Downloading Objects in Requestor Pays Buckets] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :bypass_governance_retention (Boolean)

    Specifies whether you want to delete this object even if it has a Governance-type Object Lock in place. To use this header, you must have the `s3:PutBucketPublicAccessBlock` permission.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.


1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
# File 'lib/aws-sdk-s3/object.rb', line 1679

def batch_delete!(options = {})
  batch_enum.each do |batch|
    params = Aws::Util.copy_hash(options)
    params[:bucket] = batch[0].bucket_name
    params[:delete] ||= {}
    params[:delete][:objects] ||= []
    batch.each do |item|
      params[:delete][:objects] << {
        key: item.key
      }
    end
    batch[0].client.delete_objects(params)
  end
  nil
end