I need my Windows Phone application to be able to upload audio files to my MVC3 site, using the BackgroundTransferService available in Mango.
As one possible solution, I can:
Map a route to my controller:
public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "SingleAudioFile", "Api/Audio/Recieve", new { controller = "AudioFiles", action = "Recieve" } ); }
In the controller, have a Recieve action
[HttpPost] public JsonResult Recieve(byte[] audio) { // saving and status report logic here }
My question is: How do I set the system to bind file I upload from Windows Phone to a Recieve
action's audio
byte[] parameter?
On the phone, the data is being uploaded the following way:
BackgroundTransferRequest btr = new BackgroundTransferRequest (new Uri
(siteUrl + "Api/Audio/Recieve",UriKind.Absolute));
btr.TransferPreferences = TransferPreferences.AllowBattery;
btr.Method = "POST";
btr.UploadLocation = new Uri("/" + Transfers + "/" + isoAudioFileName, UriKind.Relative);
Microsoft.Phone.BackgroundTransfer.BackgroundTransferService.Add(btr);