I am uploading files to SQL Server
- I am streaming the files from UI layer.
When it comes to Business layer here is the implementation.
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;
I am chunking the inputstream in 8KB and sending it to the response stream.
My question is ,if the length of fileToUpload.File in the business layer is 1 GB ,so will it be stored physically in the memory and affect the performance?
Or should I chunk the files from UI to memory in terms of 8KB so that calling the Business layer function 8000 times?