Example #1
0
        private static void ListBlobs(ContainerHelper containerHelper)
        {
            string containerName;

            ListContainers(containerHelper);
            Console.Write("Enter the container name you want to list the blob in: ");
            containerName = Console.ReadLine();
            if (containerHelper.ContainerExists(containerName))
            {
                var blobs = containerHelper.GetBlobs(containerName);
                Console.WriteLine();
                if (blobs?.Count() == 0)
                {
                    Console.WriteLine("Container is empty");
                }
                else
                {
                    foreach (var blob in blobs)
                    {
                        Console.WriteLine($"Name: {blob.Name}, Type: {blob.Properties.BlobType}, Tier: {blob.Properties.AccessTier}, Size: {blob.Properties.ContentLength} Bytes");
                    }
                }
            }
            else
            {
                Console.WriteLine($"No container is named {containerName}");
            }
        }
Example #2
0
 private static void DownloadContainerBlobs(ContainerHelper containerHelper, string containerName, string localFolder)
 {
     if (containerHelper.ContainerExists(containerName))
     {
         var blobs = containerHelper.GetBlobs(containerName);
         foreach (var blob in blobs)
         {
             Console.WriteLine($"Downloading {blob.Name}");
             containerHelper.DownloadBlob(containerName, blob.Name, Path.Join(localFolder, blob.Name));
             Console.WriteLine($"{blob.Name} downloaded to {Path.Join(localFolder, blob.Name)}");
         }
     }
 }
Example #3
0
 private static void CreateContainer(ContainerHelper containerHelper, string containerName)
 {
     if (!string.IsNullOrWhiteSpace(containerName))
     {
         if (containerHelper.ContainerExists(containerName))
         {
             Console.WriteLine("A container is already present with same name, see the full list of containers in the storage account");
             ListContainers(containerHelper);
         }
         else
         {
             containerHelper.CreateContainer(containerName).Wait();
         }
     }
     else
     {
         Console.WriteLine($"Name is required");
     }
 }
Example #4
0
 private static void CreateBlob(ContainerHelper containerHelper, string containerName, string localfileName)
 {
     if (containerHelper.ContainerExists(containerName))
     {
         if (File.Exists(localfileName))
         {
             var blobInfo = containerHelper.CreateBlob(containerName, new FileInfo(localfileName));
             Console.WriteLine(blobInfo?.ETag);
         }
         else
         {
             Console.WriteLine("No such file found");
         }
     }
     else
     {
         Console.WriteLine($"No container is named {containerName}");
     }
 }