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.
Container for the parameters to the DeleteObjects operation.
This operation enables you to delete multiple objects from a bucket using a single HTTP request. You may specify up to 1000 keys.
Namespace: Amazon.S3.Model
Assembly: AWSSDK.S3.dll
Version: 3.x.y.z
public class DeleteObjectsRequest : AmazonWebServiceRequest IAmazonWebServiceRequest
The DeleteObjectsRequest type exposes the following members
| Name | Description | |
|---|---|---|
|
DeleteObjectsRequest() |
| Name | Type | Description | |
|---|---|---|---|
|
BucketName | System.String |
Gets and sets the property BucketName. The bucket name containing the objects to delete. Directory buckets - When you use this operation with a directory bucket, you
must use virtual-hosted-style requests in the format Access points - When you use this action with an access point for general purpose buckets, you must provide the alias of the access point in place of the bucket name or specify the access point ARN. When you use this action with an access point for directory buckets, you must provide the access point name in place of the bucket name. When using the access point ARN, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide. Object Lambda access points are not supported by directory buckets. S3 on Outposts - When you use this action with S3 on Outposts, you must direct
requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form
|
|
BypassGovernanceRetention | System.Nullable<System.Boolean> |
Gets and sets the property BypassGovernanceRetention.
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 This functionality is not supported for directory buckets. |
|
ChecksumAlgorithm | Amazon.S3.ChecksumAlgorithm |
Gets and sets the property ChecksumAlgorithm.
Indicates the algorithm used to create the checksum for the object when you use the
SDK. This header will not provide any additional functionality if you don't use the
SDK. When you send this header, there must be a corresponding
For the
For more information, see Checking object integrity in the Amazon S3 User Guide.
If the individual checksum value you provide through
If you provide an individual checksum, Amazon S3 ignores any provided |
|
ExpectedBucketOwner | System.String |
Gets and sets the property ExpectedBucketOwner.
The account ID of the expected bucket owner. If the account ID that you provide does
not match the actual owner of the bucket, the request fails with the HTTP status code
|
|
MfaCodes | Amazon.S3.Model.MfaCodes |
Gets and sets the property MfaCodes. 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.
When performing the This functionality is not supported for directory buckets. |
|
Objects | System.Collections.Generic.List<Amazon.S3.Model.KeyVersion> |
Gets and sets the property Objects. The object to delete. Directory buckets - For directory buckets, an object that's composed entirely
of whitespace characters is not supported by the |
|
Quiet | System.Nullable<System.Boolean> |
Gets and sets the property Quiet.
Element to enable quiet mode for the request. When you add this element, you must
set its value to |
|
RequestPayer | Amazon.S3.RequestPayer |
Gets and sets the property RequestPayer. |
| Name | Description | |
|---|---|---|
|
AddKey(string) |
Add a key to the set of keys of objects to be deleted. |
|
AddKey(string, string) |
Add a key and a version to be deleted. |
This example shows how to delete multiple objects in a single request.
Note that the call may not delete all objects. In that case, an exception
will be thrown. This exception will contain the list of encountered
delete errors.
// Create a client
AmazonS3Client client = new AmazonS3Client();
// Create a DeleteObject request
DeleteObjectsRequest request = new DeleteObjectsRequest
{
BucketName = "amzn-s3-demo-bucket",
Objects = new List<KeyVersion>
{
new KeyVersion() {Key = "Item1"},
// Versioned item
new KeyVersion() { Key = "Item2", VersionId = "Rej8CiBxcZKVK81cLr39j27Y5FVXghDK", },
// Item in subdirectory
new KeyVersion() { Key = "Logs/error.txt"}
}
};
try
{
// Issue request
DeleteObjectsResponse response = await client.DeleteObjectsAsync(request);
}
catch (DeleteObjectsException doe)
{
// Catch error and list error details
DeleteObjectsResponse errorResponse = doe.Response;
if (errorResponse.DeletedObjects != null)
{
foreach (DeletedObject deletedObject in errorResponse.DeletedObjects)
{
Console.WriteLine("Deleted item " + deletedObject.Key);
}
}
if (errorResponse.DeleteErrors != null)
{
foreach (DeleteError deleteError in errorResponse.DeleteErrors)
{
Console.WriteLine("Error deleting item " + deleteError.Key);
Console.WriteLine(" Code - " + deleteError.Code);
Console.WriteLine(" Message - " + deleteError.Message);
}
}
}
.NET:
Supported in: 8.0 and newer, Core 3.1
.NET Standard:
Supported in: 2.0
.NET Framework:
Supported in: 4.7.2 and newer