The parameters to request deletion of a bucket.
Declaration Syntax
C# |
public class DeleteBucketRequest : S3Request
Members
All Members | Constructors | Methods | Properties | ||
Icon | Member | Description |
---|---|---|
DeleteBucketRequest()()()() | Initializes a new instance of the DeleteBucketRequest 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.) | |
BucketName |
The name of the bucket 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.) | |
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 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.) | |
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
All objects (including all object versions and Delete Markers) in the bucket must be
deleted before the bucket itself can be deleted.
Examples
This example shows how to delete an bucket.
CopyDeleteBucket sample
// Create a client AmazonS3Client client = new AmazonS3Client(); // Construct request DeleteBucketRequest request = new DeleteBucketRequest { BucketName = "SampleBucket" }; // Issue call DeleteBucketResponse response = client.DeleteBucket(request);
This example shows how to delete all items in a bucket, and then delete the actual bucket.
CopyDeleteBucket sample
// Create a client AmazonS3Client client = new AmazonS3Client(); // List and delete all objects ListObjectsRequest listRequest = new ListObjectsRequest { BucketName = "SampleBucket" }; ListObjectsResponse listResponse; do { // Get a list of objects listResponse = client.ListObjects(listRequest); foreach (S3Object obj in listResponse.S3Objects) { // Delete each object client.DeleteObject(new DeleteObjectRequest { BucketName = obj.BucketName, Key = obj.Key }); } // Set the marker property listRequest.Marker = listResponse.NextMarker; } while (listResponse.IsTruncated); // Construct DeleteBucket request DeleteBucketRequest request = new DeleteBucketRequest { BucketName = "SampleBucket" }; // Issue call DeleteBucketResponse response = client.DeleteBucket(request);