Norbert Pisz
Norbert Pisz

Reputation: 3440

Upload photo from Windows 8 to Azure Blob Storage

The Azure SDK don't working on Windows 8 APP.

How I can upload photo to Azure Blob Storage from Windows 8 App?

I need working code sample.

Upvotes: 0

Views: 536

Answers (1)

Sandrino Di Mattia
Sandrino Di Mattia

Reputation: 24895

You don't need the Windows Azure SDK to upload photos from Windows 8 applications to Blob Storage. The HttpClient will also work fine:

using (var client = new HttpClient())
{
     CameraCaptureUI cameraCapture = new CameraCaptureUI();
     StorageFile media = await cameraCapture.CaptureFileAsync(CameraCaptureUIMode.PhotoOrVideo);
     using (var fileStream = await media.OpenStreamForReadAsync())
     {
          var content = new StreamContent(fileStream);
          content.Headers.Add("Content-Type", media.ContentType);
          content.Headers.Add("x-ms-blob-type", "BlockBlob");

          var uploadResponse = await client.PutAsync(
                                        new Uri(blobUriWithSAS), image);
     }
}

The only thing you'll need to do is get the url to the blob together with the Signed Access Signature. Nick Harris explains how you can do this using mobile services.

Upvotes: 2

Related Questions