I wrote a series of blog posts on the WCF Data Services team blog that walks you through the (fairly complicated) process of accessing BLOB data (such as media files, documents, anything too big to return in the feed) from an OData service as a stream. My second post in this series showed how to use the WCF Data Services client to access and change BLOB data as a stream, in this case the Photo Streaming Data Service Sample.
In the process of creating this sample, I was dismayed to discover that the client was buffering the entire BLOB stream before sending it to the data service in a POST request. As you know from reading those posts, one of the big benefits of using streaming is to avoid having to buffer an entire BLOB in memory. The solution to this seemed obvious--I would just set AllowWriteStreamBuffering = false in the HttpWebRequest from the client, which I can get ahold of by handling the SendingRequest event). Ah, but the WCF Data Services client outsmarted me yet again. Apparently, the client sets properties on HttpWebRequest after the SendingRequest event fires, and it sets AllowWriteStreamBuffering = true on every request (grrrrrr).
I filed this little nasty as a bug with the product team, and it looks like it is being fixed for the next release (huzzah!).
Additional reading on streaming and OData:
- Streaming Provider (WCF Data Services)
- Working with Binary Data (WCF Data Services)
- Photo Streaming Data Service Sample
OData: There’s a feed for that…