April 2018
Intermediate to advanced
280 pages
8h 37m
English
The contents of the bucket can be listed using the following code. You can add this to a new function inside a try-catch block, similar to the previous examples:
IAmazonS3 s3Client = new AmazonS3Client(); /* create an S3 client object */ListObjectsRequest list_request = new ListObjectsRequest(); /* create a request object */list_request.BucketName = "packt-pub"; /* specify the bucket name in the object */ListObjectsResponse list_response = s3Client.ListObjects(list_request); /* invoke the request */foreach (S3Object entry in list_response.S3Objects) /* iterate through the response list */{ Console.WriteLine("key = {0} size = {1}", entry.Key, entry.Size); /* print keys and sizes */}