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.
Returns information about the DeleteObjects response and response metadata.
Namespace: Amazon.S3.Model
Assembly: AWSSDK.S3.dll
Version: 3.x.y.z
public class DeleteObjectsResponse : AmazonWebServiceResponse ISerializable
The DeleteObjectsResponse type exposes the following members
| Name | Description | |
|---|---|---|
|
DeleteObjectsResponse() |
A default constructor for DeleteObjectsResponse |
| Name | Type | Description | |
|---|---|---|---|
|
ContentLength | System.Int64 | Inherited from Amazon.Runtime.AmazonWebServiceResponse. |
|
DeletedObjects | System.Collections.Generic.List<Amazon.S3.Model.DeletedObject> |
Gets and sets the property DeletedObjects. Container element for a successful delete. It identifies the object that was successfully deleted. Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true. |
|
DeleteErrors | System.Collections.Generic.List<Amazon.S3.Model.DeleteError> |
Gets and sets the property DeleteErrors. Container for a failed delete action that describes the object that Amazon S3 attempted to delete and the error it encountered. Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true. |
|
HttpStatusCode | System.Net.HttpStatusCode | Inherited from Amazon.Runtime.AmazonWebServiceResponse. |
|
RequestCharged | Amazon.S3.RequestCharged |
Gets and sets the property RequestCharged. |
|
ResponseMetadata | Amazon.Runtime.ResponseMetadata | Inherited from Amazon.Runtime.AmazonWebServiceResponse. |
| Name | Description | |
|---|---|---|
|
GetObjectData(SerializationInfo, StreamingContext) |
Sets the System.Runtime.Serialization.SerializationInfo with information about the DeleteObjectsResponse. |
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