Reputation: 151
I now about method DownloadToStreamAsync in azure-sdk-winRT, but i can't implement this. How can i download image from blob storage, and save in to a local folder?
Upvotes: 0
Views: 814
Reputation: 136196
You can try something like below (very bare bone implementation with no error checking):
CloudStorageAccount account = new CloudStorageAccount(new StorageCredentials("accountname", "accountkey"), true);
var client = account.CreateCloudBlobClient();
var container = client.GetContainerReference("containername");
var blob = container.GetBlockBlobReference("imagename.ext");//e.g myimage.png
var file = await KnownFolders.PicturesLibrary.CreateFileAsync("imagename.ext", CreationCollisionOption.ReplaceExisting);
var stream = await file.OpenAsync(FileAccessMode.ReadWrite);
await blob.DownloadToStreamAsync(stream);
await stream.FlushAsync();
stream.Dispose();
A few comments though:
Upvotes: 2