Note that there are some explanatory texts on larger screens.

plurals
  1. POC# downloading from Windows Azure Storage returns an empty file without any exceptions
    text
    copied!<p>I'm trying to use Windows Azure Storage for my Windows Store App with Mobile Services to store images. I made uploading work by following this guide:</p> <p><a href="http://www.windowsazure.com/en-us/develop/mobile/tutorials/upload-images-to-storage-dotnet/" rel="nofollow">http://www.windowsazure.com/en-us/develop/mobile/tutorials/upload-images-to-storage-dotnet/</a></p> <p>However, I couldn't find any material on downloading the files. I couldn't even find classes reference for windows store version! If someone could guide me to the documentation I would be grateful.</p> <p>Anyway, I wrote the code but it doesn't seem work:</p> <pre><code>public static async System.Threading.Tasks.Task DownloadUserImage(SQLUser userData) { var usersFolder = await GetUsersFolder(); var imageUri = new Uri(userData.ImageUri); var accountName = "&lt;SNIP&gt;"; var key = "&lt;SNIP&gt;"; StorageCredentials cred = new StorageCredentials(accountName, key); CloudBlobContainer container = new CloudBlobContainer(new Uri(string.Format("https://{0}/{1}", imageUri.Host, userData.ContainerName)), cred); CloudBlockBlob blob = container.GetBlockBlobReference(userData.ResourceName); var imageFile = await usersFolder.CreateFileAsync(userData.Id.ToString() + ".jpg", CreationCollisionOption.ReplaceExisting); using (var fileStream = await imageFile.OpenAsync(FileAccessMode.ReadWrite)) { try { await blob.DownloadToStreamAsync(fileStream); } catch (Exception e) { Tools.HandleLiveException(e); } } } </code></pre> <p>This code results in empty file creation, but it doesn't throw any exceptions whatsoever. If I paste the value of imageUri to my browser, it starts downloading the file and completes the download successfully. However, my program does not, for some reason.</p> <p>Any help, please?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload