I want to Upload choose Photo To Parse Object here we will choose the photo From 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;
    }
}  

.. Now we want to 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();
}

Note : in parse .Net Guide the file is text encoding I think here i need to convert photo to binary how can I do it ???

有帮助吗?

解决方案

To get a byte array from the captured photo, you can use

byte[] postData = new byte[(int)e.ChosenPhoto.Length];
e.ChosenPhoto.Read(postData, 0, (int)e.ChosenPhoto.Length);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top