I have a WCF restful service that I'm trying to upload an image to. I have a very basic metod that accepts a stream as it's only parameter and is defined in the contract as:
[OperationContract]
[WebInvoke(UriTemplate = "ReviewImage", BodyStyle = WebMessageBodyStyle.Bare, Method = "POST")]
ReviewImage UploadImage(Stream data);
I'm actually consuming this service from flash (which is fairly inconsequntial) which selects a file from the file system and uploads it through the service url.
It all works seems to work, adding a breakpoint to the UploadImage method breaks as expected.
If I wanted to save this file back to disk, is it just a case of reading this Stream object into a FileStream object that creates the file somewhere? A bit like the this? When i do actually do this the file can not be opened as an image. I'm sure i'm missing a key piece of knowledge here. Does my stream actually contain just the image bytes or does it contain more than that?
EDIT AFTER ANSWER ACCEPTED:
The problem was that flash encodes image uploads as multipart/form-data which was adding aditional data to the message body. I use the MultipartParser found here to get to the actual image and write to disk.