0

I want to send a file using WCF in streaming transfer mode. At the server side I have the following code.

    public void LoadPicture(Stream stream)
    {
        FileStream file = new FileStream(GetAbsolutePath("asdf.jpg"), FileMode.CreateNew);
        byte[] buffer = new byte[bufferSize];
        int countRead;
        while ((countRead = stream.Read(buffer, 0, bufferSize)) > 0)
        {
            file.Write(buffer,0, countRead);
        }
        file.Close();            
    }

But I want to send a recomended fileName (or some additional information) somehow. How can it be done? Thanks in advance.

1 Answers1

0

In streaming mode, WCF can only send the stream itself in the message body, as you discovered. The trick to get around the problem is to use a MessageContract so you can add extra details in the header (like a suggested file name).

This question (and the MSDN link contained in it) should help: WCF: using streaming with Message Contracts

Community
  • 1
  • 1
Tridus
  • 5,021
  • 1
  • 19
  • 19