public async Task <ActionResult> ZipBlob(string blobName) { var blobRepository = new BlobStorageRepository(GetStorageSettings()); var zipFileStream = new MemoryStream(); using (ZipFile theZipFile = new ZipFile()) { List <BlobItem> blobList = await blobRepository.ListFilesAsync(blobName); foreach (BlobItem myCloudBlob in blobList) { BlobClient myBlobClient = blobRepository.CreateClient(myCloudBlob.Name); var myStream = myBlobClient.OpenRead(); // Remove first part of the path if (myCloudBlob.Name.StartsWith("Images")) { string newName = myCloudBlob.Name.Substring(7); theZipFile.AddEntry(newName, myStream); } else { theZipFile.AddEntry(myCloudBlob.Name, myStream); } } return(new ZipResult(theZipFile, "Report.zip")); } }
public async Task <ActionResult> Index() { var fileList = new List <string>(); var blobRepository = new BlobStorageRepository(GetStorageSettings()); var result = await blobRepository.ListFilesAsync(); foreach (var blobItem in result) { fileList.Add(blobItem.Name); } return(View(fileList)); }