Skip to Content
Hybrid Cloud for Developers
book

Hybrid Cloud for Developers

by Manoj Hirway
April 2018
Intermediate to advanced content levelIntermediate to advanced
280 pages
8h 37m
English
Packt Publishing
Content preview from Hybrid Cloud for Developers

Listing S3 buckets

We will extend our console application to list all the S3 buckets. We will add another function named listS3Buckets to the program and invoke that function after the createS3Bucket() function.

Add the following function to your application:

 static void listS3Buckets() {    try    {        IAmazonS3 s3Client = new AmazonS3Client();        ListBucketsResponse list_bucket_response = s3Client.ListBuckets();        foreach (S3Bucket bucket_object in list_bucket_response.Buckets)        {            Console.WriteLine("Bucket Name: {0}", bucket_object.BucketName);        }    }    catch (AmazonS3Exception s3Exception)    {        Console.WriteLine("Error!!");        Console.WriteLine(s3Exception.ErrorCode);    }}

Invoke this function by calling it from the main() function:

public static void Main(string[] ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hybrid Cloud for Architects

Hybrid Cloud for Architects

Alok Shrivastwa
OpenStack: Building a Cloud Environment

OpenStack: Building a Cloud Environment

Alok Shrivastwa, Sunil Sarat, Kevin Jackson, Cody Bunch, Egle Sigler, Tony Campbell

Publisher Resources

ISBN: 9781788830874Supplemental Content