Class DeleteObjectRequest

java.lang.Object
com.amazonaws.AmazonWebServiceRequest
com.amazonaws.services.s3.model.DeleteObjectRequest
All Implemented Interfaces:
ReadLimitInfo, Serializable, Cloneable

public class DeleteObjectRequest extends AmazonWebServiceRequest implements Serializable

Provides options for deleting a specified object in a specified bucket. Once deleted, the object can only be restored if versioning was enabled when the object was deleted.

Note: If deleting an object that does not exist, Amazon S3 returns a success message, not an error message.

See Also:
  • Constructor Details

    • DeleteObjectRequest

      public DeleteObjectRequest(String bucketName, String key)
      Constructs a new DeleteObjectRequest, specifying the object's bucket name and key.
      Parameters:
      bucketName - The name of the Amazon S3 bucket containing the object to delete.
      key - The key of the object to delete.
  • Method Details

    • getBucketName

      public String getBucketName()
      Gets the name of the Amazon S3 bucket containing the object to delete.
      Returns:
      The name of the Amazon S3 bucket containing the object to delete.
      See Also:
    • setBucketName

      public void setBucketName(String bucketName)
      Sets the name of the Amazon S3 bucket containing the object to delete.
      Parameters:
      bucketName - The name of the Amazon S3 bucket containing the object to delete.
      See Also:
    • withBucketName

      public DeleteObjectRequest withBucketName(String bucketName)
      Sets the name of the Amazon S3 bucket containing the object to delete and returns this object, enabling additional method calls to be chained together.
      Parameters:
      bucketName - The name of the Amazon S3 bucket containing the object to delete.
      Returns:
      The updated DeleteObjectRequest object, enabling additional method calls to be chained together.
    • getKey

      public String getKey()
      Gets the key of the object to delete.
      Returns:
      The key of the object to delete.
      See Also:
    • setKey

      public void setKey(String key)
      Sets the key of the object to delete.
      Parameters:
      key - The key of the object to delete.
      See Also:
    • withKey

      public DeleteObjectRequest withKey(String key)
      Sets the key of the object to delete and returns this object, enabling additional method calls to be chained together.
      Parameters:
      key - The key of the object to delete.
      Returns:
      The updated DeleteObjectRequest object, enabling additional method calls to chained together.
    • isRequesterPays

      public boolean isRequesterPays()
      Returns true if the user has enabled Requester Pays option when conducting this operation from Requester Pays Bucket; else false.

      If a bucket is enabled for Requester Pays, then any attempt to upload or download an object from it without Requester Pays enabled will result in a 403 error and the bucket owner will be charged for the request.

      Enabling Requester Pays disables the ability to have anonymous access to this bucket

      Returns:
      true if the user has enabled Requester Pays option for conducting this operation from Requester Pays Bucket.
    • setRequesterPays

      public void setRequesterPays(boolean isRequesterPays)
      Used for conducting this operation from a Requester Pays Bucket. If set the requester is charged for requests from the bucket.

      If a bucket is enabled for Requester Pays, then any attempt to upload or download an object from it without Requester Pays enabled will result in a 403 error and the bucket owner will be charged for the request.

      Enabling Requester Pays disables the ability to have anonymous access to this bucket.

      Parameters:
      isRequesterPays - Enable Requester Pays option for the operation.
    • withRequesterPays

      public DeleteObjectRequest withRequesterPays(boolean isRequesterPays)
      Used for conducting this operation from a Requester Pays Bucket. If set the requester is charged for requests from the bucket. It returns this updated DeleteObjectRequest object so that additional method calls can be chained together.

      If a bucket is enabled for Requester Pays, then any attempt to upload or download an object from it without Requester Pays enabled will result in a 403 error and the bucket owner will be charged for the request.

      Enabling Requester Pays disables the ability to have anonymous access to this bucket.

      Parameters:
      isRequesterPays - Enable Requester Pays option for the operation.
      Returns:
      The updated DeleteObjectRequest object.