The parameters to request deletion of one or more objects from a bucket.
Declaration Syntax
C# |
public class DeleteObjectsRequest : S3Request
Members
All Members | Constructors | Methods | Properties | ||
Icon | Member | Description |
---|---|---|
DeleteObjectsRequest()()()() | Initializes a new instance of the DeleteObjectsRequest class | |
AddHeader(String, String) |
Adds the header to the collection of headers for the request.
(Inherited from S3Request.) | |
AddHeaders(NameValueCollection) |
Adds all of the specified key/value pairs into the request headers collection.
(Inherited from S3Request.) | |
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.
| |
AddKey(KeyVersion) |
Add a KeyVersion object representing the S3 object to be deleted.
| |
AddKeys(array<KeyVersion>[]()[][]) |
Add one or more KeyVersion objects representing the S3 objects to be deleted.
| |
BucketName |
The name of the bucket containing the objects to be deleted.
| |
Equals(Object) | (Inherited from Object.) | |
GetHashCode()()()() | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType()()()() | Gets the type of the current instance. (Inherited from Object.) | |
InputStream |
Input stream for the request; content for the request will be read from the stream.
(Inherited from S3Request.) | |
Keys |
A collection of KeyVersion objects representing the S3 objects that should be deleted.
| |
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.
| |
Quiet |
Toggles between Quiet and Verbose mode for the operation.
If set to true (Quiet mode), the response includes only those keys for objects on which
the delete operation failed.
| |
ReadWriteTimeout |
Overrides the default HttpWebRequest ReadWriteTimeout value.
(Inherited from S3Request.) | |
Timeout |
Overrides the default HttpWebRequest timeout value.
(Inherited from S3Request.) | |
ToString()()()() | (Inherited from S3Request.) | |
WithBucketName(String) | Obsolete.
Sets the name of the bucket containing the objects to be deleted.
| |
WithInputStream(Stream) | Obsolete.
Sets an input stream for the request; content for the request will be read from the stream.
(Inherited from S3Request.) | |
WithKeys(array<KeyVersion>[]()[][]) | Obsolete.
Add one or more KeyVersion objects representing the S3 objects to be deleted.
| |
WithMfaCodes(String, String) | Obsolete.
The MfaCodes Tuple associates the Serial Number and the current Token/Code displayed on the
Multi-Factor Authentication device associated with your AWS Account.
| |
WithQuiet(Boolean) | Obsolete.
Toggles between Quiet and Verbose mode for the operation.
If set to true (Quiet mode), the response includes only those keys for objects on which
the delete operation failed.
| |
WithReadWriteTimeout(Int32) | Obsolete.
Overrides the default HttpWebRequest ReadWriteTimeout value.
(Inherited from S3Request.) | |
WithTimeout(Int32) | Obsolete.
Overrides the default HttpWebRequest timeout value.
(Inherited from S3Request.) |
Remarks
When performing a multi-object delete operation on an MFA Delete enabled bucket, that attempts to delete any versioned objects,
you must include an MFA token. If you do not provide one, the entire request will fail, even if there are non versioned objects
you are attempting to delete. If you provide an invalid token, whether there are versioned keys in the request or not, the entire
multi-object delete request will fail.
Examples
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.
CopyDeleteObjects sample
// Create a client AmazonS3Client client = new AmazonS3Client(); // Create a DeleteObject request DeleteObjectsRequest request = new DeleteObjectsRequest { BucketName = "SampleBucket", Keys = new List<KeyVersion> { new KeyVersion("Item1"), // Versioned item new KeyVersion("Item2", "Rej8CiBxcZKVK81cLr39j27Y5FVXghDK"), // Item in subdirectory new KeyVersion("Logs/error.txt") } }; try { // Issue request DeleteObjectsResponse response = client.DeleteObjects(request); } catch (DeleteObjectsException doe) { // Catch error and list error details DeleteObjectsErrorResponse errorResponse = doe.ErrorResponse; foreach (DeletedObject deletedObject in errorResponse.DeletedObjects) { Console.WriteLine("Deleted item " + deletedObject.Key); } foreach (DeleteError deleteError in errorResponse.DeleteErrors) { Console.WriteLine("Error deleting item " + deleteError.Key); Console.WriteLine(" Code - " + deleteError.Code); Console.WriteLine(" Message - " + deleteError.Message); } }