AWS SDK Version 2 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

.NET Framework 3.5
 
The parameters to request deletion of an object in a bucket. The operation removes the null version (if there is one) of an object and inserts a delete marker, which becomes the latest version of the object.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceRequest
    Amazon.S3.Model.DeleteObjectRequest

Namespace: Amazon.S3.Model
Assembly: AWSSDK.dll
Version: (assembly version)

Syntax

C#
public class DeleteObjectRequest : AmazonWebServiceRequest
         IRequestEvents

The DeleteObjectRequest type exposes the following members

Constructors

NameDescription
Public Method DeleteObjectRequest()

Properties

NameTypeDescription
Public Property BucketName System.String The name of the bucket containing the object to delete.
Public Property Key System.String The key identifying the object to delete.
Public Property MfaCodes Amazon.S3.Model.MfaCodes The MfaCodes Tuple associates the Serial Number and the current Token/Code displayed on the Multi-Factor Authentication device associated with your AWS Account.
Public Property VersionId System.String The identifier for the specific version of the object to be deleted, if required.

Examples

This example shows how to delete an object.

DeleteObject sample


// Create a client
AmazonS3Client client = new AmazonS3Client();

// Create a DeleteObject request
DeleteObjectRequest request = new DeleteObjectRequest
{
    BucketName = "SampleBucket",
    Key = "Item1"
};

// Issue request
client.DeleteObject(request);

                

Remarks

To remove a specific version, you must be the bucket owner and you must use the versionId subresource. Using this subresource permanently deletes the version.

If the object you want to delete is in a bucket where the bucket versioning configuration is MFA Delete enabled, you must include specify the MFA serial number and value in the request.

If there isn't a null version, Amazon S3 does not remove any objects.

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

.NET for Windows Store apps:
Supported in: Windows 8.1, Windows 8

.NET for Windows Phone:
Supported in: Windows Phone 8.1, Windows Phone 8