我想上传选择Photo To Parse Object 在这里,我们将选择照片来自galery
private void ChosePhoto_Click(object sender, RoutedEventArgs e)
{
CamerChoooserTask = new PhotoChooserTask();
CamerChoooserTask.Completed += new EventHandler<PhotoResult>(CamerChoooserTask_Completed);
CamerChoooserTask.Show();
}
private void CamerChoooserTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK && e.ChosenPhoto != null)
{
imgto.Source = null;
MessageBox.Show(e.ChosenPhoto.Length.ToString());
App.ChoosedImage = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
imgto.Source = App.ChoosedImage;
}
}
.. 现在我们想要Uplaod to Object
private async void UploadPhotoBtn_Click(object sender, RoutedEventArgs e)
{
// here I want to but my photo in array ..
byte[] data = System.Text.Encoding.UTF8.GetBytes("Working at Parse is great!");
ParseFile file = new ParseFile("resume.txt", data);
var photo = new ParseObject("photo");
photo["Photo"] = file;
await photo.SaveAsync();
}
注意:在解析.Net指南中,文件是文本编码 我想在这里我需要将照片转换为二进制 我该怎么办?
答案 0 :(得分:2)
要从捕获的照片中获取字节数组,可以使用
byte[] postData = new byte[(int)e.ChosenPhoto.Length];
e.ChosenPhoto.Read(postData, 0, (int)e.ChosenPhoto.Length);