KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have created a simple WCF service to prototype file uploading. The service: [ServiceContract] public class Service1 { [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "/Upload")] public void Upload(Stream stream) { using (FileStream targetStream = new FileStream(@"C:\Test\output.txt", FileMode.Create, FileAccess.Write)) { stream.CopyTo(targetStream); } } } It uses webHttpBinding with transferMode set to "Streamed" and maxReceivedMessageSize , maxBufferPoolSize and maxBufferSize all set to 2GB. httpRuntime has maxRequestLength set to 10MB. The client issues HTTP requests in the following way: HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(@"http://.../Service1.svc/Upload"); request.Method = "POST"; request.SendChunked = true; request.AllowWriteStreamBuffering = false; request.ContentType = MediaTypeNames.Application.Octet; using (FileStream inputStream = new FileStream(@"C:\input.txt", FileMode.Open, FileAccess.Read)) { using (Stream outputStream = request.GetRequestStream()) { inputStream.CopyTo(outputStream); } } Now, finally, what's wrong: When uploading the file 100MB big, the server returns HTTP 400 (Bad request). I've tried to enable WCF tracing, but it shows no error. When I increase httpRuntime . maxRequestLength to 1GB, the file gets uploaded without problems. The MSDN says that maxRequestLength " specifies the limit for the input stream buffering threshold, in KB ". This leads me to believe that the whole file (all 100MB of it) is first stored in "input stream buffer" and only then it is available to my Upload met
Tags (comma-separated)
Save Edits
Cancel