我正在开发windows phone 8应用程序,我需要在其中记录并将12秒视频上传到服务器。我正在使用restsharp工具包上传视频。但是,当我尝试录制和上传视频时,从API获取Outofmemory异常或NULL响应。但是这个相同的代码在模拟器中运行良好。我对这个问题不太了解,有人可以帮忙吗?
我正在使用以下代码将视频上传到服务器。
public void postVideofile()
{
customIndeterminateProgressBar.Visibility = Visibility.Visible;
tbkloading.Visibility = Visibility.Visible;
isoVideoFile = new IsolatedStorageFileStream(isoVideoFileName, FileMode.Open, FileAccess.Read, IsolatedStorageFile.GetUserStoreForApplication());
StreamReader reader = new StreamReader(isoVideoFile);
DateTime dt = DateTime.Now;
////preparing RestRequest by adding server url, parameteres and files...
RestRequest request = new RestRequest("http://slv1.socialnetgate.com/v1/files/postVideofile", Method.POST);
request.AddParameter("apikey", "RVY0VnVLUDhQSHZST2hFM04xcnFnZDkzU2J2bGtZVVM1S2NNaXY2NHh4cmhhdEM5cjMyMTJaMXA");
request.AddParameter("userID", "64");
request.AddFile("uploadedfile", App.ReadToEnd(reader.BaseStream), isoVideoFileName);
request.AddParameter("uploadID", dt);
//calling server with restClient
RestClient restClient = new RestClient();
restClient.ClearHandlers();
restClient.AddHandler("application/json", new XmlDeserializer());
restClient.AddHandler("text/json", new XmlDeserializer());
restClient.ExecuteAsync(request, (response) =>
{
if (response.StatusCode == HttpStatusCode.OK)
{
string err = response.ErrorMessage;
String res = response.Content;
JObject results = JObject.Parse(res);
string jsonStatus = (string)results["header"]["description"];
string url = (string)results["URL"];
}
else
{
MessageBox.Show("Check your internet connection! Please try again");
}
});
}