I want to send large files >800 mb to cassansdra storage.But I am getting System.OutOfMemoryException .
Please find the code below:
HttpWebRequest request = WebRequest.Create(postUrl) as HttpWebRequest;
Stream requestStream = request.GetRequestStream();
byte[] buffer = new byte[8 * 1024];
int len;
while ((len = fileToUpload.File.Read(buffer, 0, buffer.Length)) >0)
{
requestStream.Write(buffer, 0, len);
requestStream.Flush();
}
return request.GetResponse() as HttpWebResponse;
Please suggest me which part of the code needs improvement?
fileToUpload is the exact stream of 800 MB from UI.