【问题标题】:Upload photo from Windows 8 to Azure Blob Storage将照片从 Windows 8 上传到 Azure Blob 存储
【发布时间】:2013-02-27 22:15:57
【问题描述】:

Azure SDK 不适用于 Windows 8 APP。

如何将照片从 Windows 8 应用程序上传到 Azure Blob 存储?

我需要工作代码示例。

【问题讨论】:

标签: azure windows-8


【解决方案1】:

您不需要 Windows Azure SDK 即可将照片从 Windows 8 应用程序上传到 Blob 存储。 HttpClient 也可以正常工作:

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);
     }
}

您唯一需要做的就是获取 blob 的 URL 以及签名访问签名。 Nick Harris explains 如何使用移动服务做到这一点。

【讨论】:

  • 谢谢,但是我应该在 new URI() 中输入什么 url?
  • 我收到错误:请求 URI 中指定的查询参数之一的值无效
猜你喜欢
  • 2013-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-28
  • 2019-05-26
  • 1970-01-01
  • 1970-01-01
  • 2014-08-23
相关资源
最近更新 更多