C# |
ListObjectsResponse ListObjects( ListObjectsRequest request )
- request (ListObjectsRequest)
- The ListObjectsRequest that defines the parameters of the operation.
Since buckets can contain a virtually unlimited number of objects, the complete results of a list query can be extremely large. To manage large result sets, Amazon S3 uses pagination to split them into multiple responses. Callers should always check the IsTruncated to see if the returned listing is complete, or if callers need to make additional calls to get more results. The marker parameter allows callers to specify where to start the object listing.
List performance is not substantially affected by the total number of keys in your bucket, nor by the presence or absence of any additional query parameters. The list can be filtered via the Marker property of the ListObjectsRequest.
In order to List Objects, you must have READ access to the bucket.
This example shows how to list all objects in a bucket.
// Create a client AmazonS3Client client = new AmazonS3Client(); // List 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) { Console.WriteLine("Object - " + obj.Key); Console.WriteLine(" Size - " + obj.Size); Console.WriteLine(" LastModified - " + obj.LastModified); Console.WriteLine(" Storage class - " + obj.StorageClass); } // Set the marker property listRequest.Marker = listResponse.NextMarker; } while (listResponse.IsTruncated);
Exception | Condition |
---|---|
ArgumentNullException | |
WebException | |
AmazonS3Exception |