【问题标题】:Upload image to Azure blob storage from Windows Phone. Not creating将图像从 Windows Phone 上传到 Azure Blob 存储。不创建
【发布时间】:2013-12-18 02:27:14
【问题描述】:

我正在使用 Windows Azure 在我的 Windows Phone 应用程序中存储图像。

相机拍摄一张照片,然后上传所选照片流。但是它没有抛出错误但没有上传?

            var blobContainer = CloudStorageContext.Current.Resolver.CreateCloudBlobClient();
            var container = blobContainer.GetContainerReference("pics");


            var blob = container.GetBlobReference("picture.jpg");
            blob.UploadFromStream(e.ChosenPhoto, response => { MessageBox.Show(blob.Uri.ToString()) });

我不知道发生了什么。解析器包含正确的用户、密钥和 url。容器“图片”确实存在,但没有上传图像。消息框弹出一个不存在的url。

更新 - 这里似乎发布了一个类似(几乎相同)的问题 - Uploading a photo stream from camera into azure blob in WP7。然而,大写的容器名称在这里不是问题,因此解决方案没有解决这个问题

【问题讨论】:

  • 您如何尝试验证文件是否已上传?一个常见问题是,当 blob 容器未设置为公共访问时,您尝试通过调用存储帐户上的 URi 进行验证。
  • 两种方式。使用 CloudXplorer 并登录到我的 Azure 帐户,实际上是通过 Windows azure 仪表板manage.windowsazure.com

标签: c# azure windows-phone azure-storage azure-blob-storage


【解决方案1】:

我有一个应用程序 (Windows Phone 8),它将拍摄的图像上传到 Azure webrole,然后将图像存储在 Azure 存储 Blob 中。下面的代码是服务器存储图像的方式。同样,这段代码不能在手机上运行,​​但您可以将其作为参考。

                string randomGUID = locationID
                + "-"
                + Guid.NewGuid().ToString();

            //Retrieve storage account from application settings
            CloudStorageAccount storageAccount = GetStorageAccount();

            //Create blob client
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            //Retrieve reference to images container
            CloudBlobContainer container = blobClient.GetContainerReference(
                RoleEnvironment.GetConfigurationSettingValue("BlobContainer"));                    

            //Retrieve references to the blob inside the container
            CloudBlockBlob blockBlob = container.GetBlockBlobReference(randomGUID);

            blockBlob.UploadFromStream(imageToUpload);

变量imageToUpload的类型是Stream

如您所见,这是非常简单的代码。也许您的问题与 UploadFromStream 中的 lambda 表达式有关?

【讨论】:

    猜你喜欢
    • 2013-04-13
    • 2014-01-27
    • 2021-01-16
    • 2018-12-17
    • 1970-01-01
    • 2013-01-04
    • 2013-07-29
    • 2020-01-25
    • 1970-01-01
    相关资源
    最近更新 更多