且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

上传图片从Windows Azure的电话Blob存储。没有创造

更新时间:2023-02-09 08:41:44

我有上传带到一个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?