VS2010 B2, ADO.NET Data Service backed by an Entity Framework model of an SQL Server 2008 AdventureWorks database.
Calling http://localhost/AdventureWorks.svc/ProductPhotoes(69)/ThumbNailPhoto/$value returns an image of bicycle, as expected. Apparently, there is some special magic somewhere that indicates the mime type or IE just knows it's an image. I think the later.
However, I'm more intrested in returning an mp3 from the database and specifying a mime-type. So I've updated a single record in the AW database and replaced the ThumbNailPhoto varbinary(max) contents with a Coldplay mp3. When I run the same query as above, I'm prompted to save the file.
My next step was to create a Service Operation called GetProductAudio that returns the binary data. I used the [System.Data.Services.MimeType("GetProductAudio", "audio/mpeg")] attribute on the DS class and it works exactly as expected. I query the service and Viva La Vida starts playing in Windows Media Player.
The /ThumbNailPhoto/$value and GetProductAudio are retreiving and returning the same data, the only difference is that GetProductAudio specifies a mime type.
1. How do I specify the mime type for ThumbNailPhoto so when I use the $value operator the binary data comes down with a mime type in the response header? From other posts I've read, it sounds like I should be able to specify a MimeType="audio/mpeg" attribute in the EF CSDL for the ThumbNailPhoto property, but I've had no luck in doing this. http://social.msdn.microsoft.com/Forums/en/adodotnetdataservices/thread/05b3bec2-ebed-4fc0-bb5b-e2d3be5fe3b7 and http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/818a7491-45ef-4bce-9c4a-bbcfd2151785/ and http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/f0a559be-1681-43ce-8c91-5eed289df24f
The xmlns being used in the examples above don't seem to exist in VS2010 B2. It seems like it would be easier to modify the CSDL with an attribute than create a Service Operation everytime you want to specify a mime type for a property's $value operator.
2. Of lesser importance. Why is the System.Data.Services.MimeTypeAttribute marked as AllowMultiple = false? It seems as though I would need to decorate the Data Service class with a MimeType attribute for each ServiceOperation that needed a specific mime type specified. So if I had 3 Service Operations that I wanted to control the Mime Type, how would I do that if they were all different types?
Thanks,
Greg