WCF passing filestream
c#, filestream, wcf
Solution
There are 2 modes in WCF: streamed vs buffered transfer. You are looking for the streamed transfer mode to avoid loading the entire data in memory:
Windows Communication Foundation (WCF) can send messages using either buffered or streamed transfers. In the default buffered-transfer mode, a message must be completely delivered before a receiver can read it. In streaming transfer mode, the receiver can begin to process the message before it is completely delivered. The streaming mode is useful when the information that is passed is lengthy and can be processed serially. Streaming mode is also useful when the message is too large to be entirely buffered.
To enable streaming, define the OperationContract appropriately and enable streaming at the transport level.
Problem
As I know, when I put a file in filestream, the file does not exsist in memory. But is it true that when I pass that filestream to my service from my client, the client put the file in the momory and only then send the byte[] to the service?