Windows Phone将图像上传到azure blob服务

时间:2014-01-09 10:01:35

标签: c# azure windows-phone-8 azure-storage azure-storage-blobs

我想将手机上的照片上传到azure blob。

我正在使用此链接 http://www.windowsazure.com/en-us/develop/mobile/tutorials/upload-images-to-storage-wp8/

没有错误或异常,它只是我看不到它,我知道绑定是正确的, 即使我打开图像的链接,也没有找到照片。

这里有一个与此类似的问题 Upload image to Azure blob storage from Windows Phone. Not creating

这就是我正在做的事情

PhotoChooserTask chooser;
protected override void OnNavigatedTo(NavigationEventArgs e)
{
    Refresh();
    base.OnNavigatedTo(e);
}
private void PhotoChooserBtn_Click(object sender, RoutedEventArgs e)
{
    chooser = new PhotoChooserTask();
    chooser.Completed += chooser_Completed;
    chooser.Show();
}

Stream stream = null;
void chooser_Completed(object sender, PhotoResult e)
{
    stream = e.ChosenPhoto;
    BitmapImage sourceImg = new BitmapImage();
    sourceImg.SetSource(stream);

    ProfileImage.Source = sourceImg;
}

async private void SaveBtn_Click(object sender, RoutedEventArgs e)
{
    Images images = new Images() { Username = "7elbeh" };
    InsertImage(images);
}

private void RefreshBtn_Click(object sender, RoutedEventArgs e)
{
    Refresh();
}

请帮忙。

1 个答案:

答案 0 :(得分:1)

我有同样的错误,解决我将我的Stream转换为数组并使用UploadFromByteArrayAsync

byte[] array = imageStream.ToArray(); await blobFromSASCredential.UploadFromByteArrayAsync(array, 0, array.Length);