vendredi 2 janvier 2015

Retrieving a ParseFile from within a ParseObject - Android C# Xamarin Parse

I've been struggling with this for a while now. I've managed to create an app using Xamarin & C# (for android). The app successfully sends a voice recording to my Parse folder(https://parse.com/). From the dashboard on the parse website, I can download the sound file and play it successfully.


I need to be able to download and play the sound from within the app though. So far, I can retrieve the parseObject that contains the parseFile containing the sound in bytes. I don't know how to go into that parseObject and extract the file though.


Here's how I send the data:



byte[] data = File.ReadAllBytes(LoadPath);


ParseFile file = new ParseFile(savetheFile, data);


await file.SaveAsync();


var auidoParseObject = new ParseObject("AudioWithData");
//Console.WriteLine(ParseUser.getUserName());


if (ParseUser.CurrentUser != null)
{
tempUserName = ParseUser.CurrentUser.Username.ToString();
}



else
{
tempUserName = "Anonymous";
}
Console.WriteLine("PARSE USERNAME: " + tempUserName);
auidoParseObject["userName"] = tempUserName;
auidoParseObject["file"] = file;
await auidoParseObject.SaveAsync();


And here's my attempt to retrieve it form the parse cloud:



var query1 = ParseObject.GetQuery ("AudioWithData")
.WhereEqualTo ("userName", username);



IEnumerable<ParseObject> results1 = await query1.FindAsync();



Console.WriteLine ("At 0:" + results1.ElementAt (0).ToString ());
Console.WriteLine("At 1:" + results1.ElementAt (1).ToString());
Console.WriteLine("At 2:" + results1.ElementAt (2).ToString());

Here, the console will write:
At 0:Parse.ParseObject
At 1:Parse.ParseObject
At 2:Parse.ParseObject


I now need to extract the "file" part of that parseObject... but HOW!?


Any help would be GREATLY appreciated, Thanks!


Aucun commentaire:

Enregistrer un commentaire