我的windows phone应用要上传音频文件到MVC3 站点,使用Mango的BackgroundTransfer service。
可能可以这么做,
1.map一个路径到controller:- public override void RegisterArea(AreaRegistrationContext context)
- {
- context.MapRoute(
- "SingleAudioFile",
- "Api/Audio/Recieve",
- new { controller = "AudioFiles", action = "Recieve" }
- );
- }
复制代码 2.在controller里,有个Receive action:- [HttpPost]
- public JsonResult Recieve(byte[] audio)
- {
- // saving and status report logic here
- }
复制代码
我的问题是怎么绑定要上传的文件到Receive Action 的音频字节参数?
这是我上传数据的方法:
- 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);
复制代码 |
|