How to upload large byte array on server by WCF service?

Apr 7 2015 6:08 AM
Hi,
I have services on both ends. A service is passing large byte array to another service. But failing.
I have configured both services for large data. But I am getting Out of memory exception when calling the following code.
var data = JsonConvert.SerializeObject(bytes); // bytes is byte array of file approx size of 50mb.
//Create method Uri
var uri = new Uri(url);
using (HttpClient client = new HttpClient())
{
client.BaseAddress = new Uri(Utility.ServiceBaseUri);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.Timeout = new TimeSpan(0, 10, 0);
HttpResponseMessage response = client.PostAsJsonAsync(uri.ToString(), data).Result; //Exception Out of memory....
if (response.IsSuccessStatusCode)
{

}
}
 

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (4)