I’m POSTing a file to a WCF REST service through a HTML form, with enctype set to multipart/form-data and a single component: <input type="file" name="data">. The resulting stream being read by the server contains the following:
------WebKitFormBoundary
Content-Disposition: form-data; name="data"; filename="DSCF0001.JPG"
Content-Type: image/jpeg
<file bytes>
------WebKitFormBoundary--
The problem is that I’m not sure how do extract the file bytes from the stream. I need to do this in order to write the file to the disk.
You may take a look at the following blog post which illustrates a technique that could be used to parse
multipart/form-dataon the server using the Multipart Parser:Another possibility is to enable aspnet compatibility and use
HttpContext.Current.Requestbut that’s not a very WCFish way.