Skip to content

Instantly share code, notes, and snippets.

@chester89
Created May 18, 2014 22:32
Show Gist options
  • Save chester89/5d6a62633abab3969c32 to your computer and use it in GitHub Desktop.
Save chester89/5d6a62633abab3969c32 to your computer and use it in GitHub Desktop.
List all objects in a bucket using Google Storage API
try
{
// Create the service.
var service = new StorageService(new BaseClientService.Initializer
{
ApplicationName = "TestinInTheCloud",
ApiKey = "API-KEY"
});
// Run the request.
Console.WriteLine("Executing a list request...");
var result = service.Objects.List("bucket-name").Execute();
// Display the results.
if (result.Items != null)
{
foreach (var api in result.Items)
{
Console.WriteLine(api.Id + " - " + api.Name);
}
}
}
catch (AggregateException ex)
{
foreach (var e in ex.InnerExceptions)
{
Console.WriteLine("Error: " + e.Message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment