locked
Select and Upload Multiple Images to Azure Blob using Windows Store App

    Question

  • I am trying to upload multiple images to azure Blob after selecting  through File Picker  

    I am trying to upload multiple images to azure Blob after selecting  through File Picker  and preview them to  
    
    after uploading in Application
    
      private async void PickFilesButton_Click(object sender, RoutedEventArgs e)
            {
                FileOpenPicker openPicker = new FileOpenPicker();
                openPicker.ViewMode = PickerViewMode.List;
                openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                openPicker.FileTypeFilter.Add(".jpg");
                openPicker.FileTypeFilter.Add(".jpeg");
                openPicker.FileTypeFilter.Add(".png");  
                IReadOnlyList<StorageFile> files = await openPicker.PickMultipleFilesAsync();
                if (files.Count > 0)
                {
                    StringBuilder output = new StringBuilder("Picked files:\n");
                    // Application now has read/write access to the picked file(s)
                    foreach (StorageFile file in files)
                    {
                       
                        output.Append(file.Name + file.Path + "\n");
    
                         UploadFile(file);
    
                    }
                    OutputTextBlock.Text = output.ToString();
                     
                }
                else
                {
                    OutputTextBlock.Text = "Operation cancelled.";
                }
            }
    
            private async void UploadFile(StorageFile files)
            {
                string accountName = ""; // storage account name
                string accountKey = "";   access keyy
                try
                {
                    StorageCredentials creds = new StorageCredentials(accountName, accountKey);
                    CloudStorageAccount account = new CloudStorageAccount(creds, useHttps: true);
                    CloudBlobClient client = account.CreateCloudBlobClient();
                    CloudBlobContainer sampleContainer = client.GetContainerReference(""); // container name
                    sampleContainer.CreateIfNotExistsAsync();
    
                    CloudBlockBlob blob = sampleContainer.GetBlockBlobReference(files.Name);
    
                    //Before uploading, set the progress ring to be active to show progress
                    ProgressRing1.IsActive = true;
    
                    await blob.UploadFromFileAsync(files);
                    //After uploading is complete, stop progress ring progress
                    ProgressRing1.IsActive = false;
    
                    //Preview the image by pointing to the Uri of the container
                    ProgressRing1.IsActive = false;
                    ImageSource imgSource = new BitmapImage(blob.Uri);
                    //imageGrid.ItemsSource = imgSource;
                }
                catch (Exception ex)
                {
                    MessageDialog dialog = new MessageDialog(ex.ToString());
                    dialog.ShowAsync();
                }
            }
    
     

    Sunday, June 22, 2014 3:38 PM

All replies

  • Hi,

    There is not enough information to detect what do you want to do. You should describe your problem in detail. Do you have some problems in uploading multiple images to azure Blob or you cannot know how to display the files.

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, June 23, 2014 2:35 AM