I've set up an Azure Blob Storage to upload/download file.
ProcessAsync(Folderpath, rows.Item("FileName"), rows.Item("Extension")).GetAwaiter().GetResult()
System.IO.File.Move(Folderpath + "\" + rows.Item("FileName"), AchivePath + "\" + rows.Item("FileName"))
WriteToLog("Extracted File : " + rows.Item("FileName") + " ", "")
DownloadBlobSnapshot(rows.Item("FileName"), rows.Item("Extension")).GetAwaiter().GetResult()
Currently, I am able to store my file locally in my desktop. How do I save and display the file on .net MVC
platform with Using and MemoryStream/FileStream?
Or alternatively, is there any better way in doing so?
Edit 1: (Based on Ivan's Answer)
Private Shared Async Function DownloadBlobSnapshot(FileName As String, Extension As String) As Task
Dim storageAccount As CloudStorageAccount
Dim storageConnectionString As String = ConfigurationManager.AppSettings("StorageConnectionString")
Dim accountName As String = myaccountname
Dim accountKey As String = myaccountkey
Dim cred = New StorageCredentials(accountName, accountKey)
Dim account = New CloudStorageAccount(cred, True)
Dim client = account.CreateCloudBlobClient()
Dim container = client.GetContainerReference(FileName.Replace(Extension, ""))
Dim listOfBlobs As IEnumerable = container.ListBlobs(Nothing, True, BlobListingDetails.Snapshots)
If CloudStorageAccount.TryParse(storageConnectionString, storageAccount) Then
For Each item In listOfBlobs
Dim blockBlob As CloudBlockBlob = container.GetBlockBlobReference((CType(item, CloudBlockBlob)).Name)
blockBlob.DownloadToStream(Response.OutputStream)
Next
//ToDO
End If
End Function
But I'd realised Response
is not available in Shared
Function.