上传图片从Windows Azure的电话Blob存储。没有创造 [英] Upload image to Azure blob storage from Windows Phone. Not creating

查看:173
本文介绍了上传图片从Windows Azure的电话Blob存储。没有创造的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using Windows Azure to store images in my windows phone application.

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

The camera takes a photo and the chosen photo stream is then uploaded. However it is throwing NO error but is not uploading?

            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。

I don't have a clue what is happening. The Resolver contains the correct user, key and urls. The container "pics" does exist, but no image is being uploaded. The message box pops up with a url which does not exist.

更新 - 似乎有在这里发表simular(以及几乎相同)的问题 - <一个href=\"http://stackoverflow.com/questions/10348439/uploading-a-photo-stream-from-camera-into-azure-blob-in-wp7\">Uploading从相机照片流进WP7 蔚蓝的blob。然而,大写容器名称是不是一个问题在这里,这样的解决方案并没有解决这个问题。

UPDATE - There seems to be a simular (well almost identical) question posted here - Uploading a photo stream from camera into azure blob in WP7. However the upper case container name is not an issue here, so that solution did not fix this

推荐答案

我有上传带到一个Azure的webrole图像,应用程序(的Windows Phone 8)这反过来存储在一个Azure存储的Blob的形象。在code以下就是服务器存储的图像。同样,这code不在手机上运行,​​但你可以用它作为参考。

I have an application (Windows Phone 8) that uploads an image taken to an Azure webrole, which in turn stores the image in an Azure Storage Blob. The code below is how the server stores the images. Again, this code does not run on the phone, but you can use it as a reference.

                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 的就是该类型

正如你所看到的,这是pretty简单code。也许你的问题与你的 UploadFromStream

As you can see, this is pretty straightforward code. Perhaps your problem has to do with the lambda expression you have in UploadFromStream?

这篇关于上传图片从Windows Azure的电话Blob存储。没有创造的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆