Streaming files (more than one) for an Entity. RRS feed

  • Question

  • I have an Entity (EF4) with 3 properties (strings) representing URLS pointing rispectively to 2 images and 1 pdf.

    I wanted to serve this files using WCF data services. I've achieved my porpouse, using an Operation Service (GetEntityData) that accept the ID(int) of the Entity and the property name (string) pointing to the requested file and returns an array of bytes. This works, and I've have even successful changed the content type returned by the method using the ProcessingPipeline property. But the application must first load in memory the whole file and then send it to the wire. I don't know if this can lead to crashes or out of memory exceptions with big files or freeze the responsiveness of the entire service.

    I'd like to serve this data using a streaming service. I know that Data Services can stream content using IDataServiceStreamProvider, but it seems that you can assign only one stream to one entity object (like the employee's photo) and examples in the "www" are very poor.

    Someone knows how can I achieve this behaviour? 

    Thanks in advance.

    Saturday, September 4, 2010 1:32 PM


  • Hi,

    Currently WCF Data Services (as well as the OData protocol) only supports a single stream per entity. We are aware of the request to support multiple streams and we are considering it for our next release.

    Currently the suggested "workaround" is to introduce a new entity type (StreamEntity or something like that) and then have a navigation property from the original entity which will point to all the streams associated with that entity. Then you can enable the default stream on the StreamEntity and return the data that way.


    Vitek Karas [MSFT]
    Tuesday, September 7, 2010 4:07 PM