Webapi: [Feature] Add Stream Support to WebApi

Created on 5 May 2015  路  14Comments  路  Source: OData/WebApi

Add contents for Stream support in OData V4 on odata.github.io/WebApi.

We have related questions on StackOverflow

P1 backlog feature

Most helpful comment

@madansr7 please prioritize.

All 14 comments

Consider to support named stream (aka stream property) or media link entry (i.e., media entry)
If named stream, we need to change OData entry serializer.

``` c#
public class CustomODataEntityTypeSerializer : ODataEntityTypeSerializer
{
public CustomODataEntityTypeSerializer(IEdmEntityTypeReference entityType, ODataSerializerProvider serializerProvider)
: base(entityType, serializerProvider)
{
}

public override ODataProperty CreateStructuralProperty(IEdmStructuralProperty structuralProperty, object entityInstance, ODataSerializerContext writeContext)
{
    if (structuralProperty.Type.IsStream())
    {
        return new ODataProperty { Name = structuralProperty.Name, Value = new ODataStreamReferenceValue { ReadLink = new Uri("http://image") } };
    }

    return base.CreateStructuralProperty(structuralProperty, entityInstance, writeContext);
}

}

If media link entry, we need to create an entity type with HasStream set to true in OData v4.  E.g., use this ctor:

``` c#
public EdmEntityType(string namespaceName, string name, IEdmEntityType baseType, bool isAbstract, bool isOpen, bool hasStream);

The change is in model builder.

thanks @congysu Is this issue accepted for next release of libraries?

For interim do you have any suggestion on how we can go ahead and add the stream support.

@sammym1982 The related issue is https://github.com/OData/WebApi/issues/149. Can start from a blog: http://blogs.msdn.com/b/mrtechnocal/archive/2013/12/31/10462258.aspx, although it is for OData v3 Web API.

@congysu

I do tried porting that code to V4 but the issue as I mentioned in my original post on stackoverflow is there is currently no way available to mark an entity as HasStream = true. The original IEdmModel.SetHasDefaultStream seems like no longer available.

Model we have is as followos:

Entity: Incident
NavigationProperties Collection: Attachments

Therefore We want all our attachment posts to happen as below:

POST: http://foo.com/incidents(1L)/Attachments

@sammym1982 I have a pr #379 , expose the HasStream Property, which is helpful to your customize, would you help to review?

Guys any news on this.
We are working with OData v 4.0 and now we are completely stuck, which is very disappointing.
Can you implement in the model builder this extension and release a fixture over Nuget ASAP?

Pinging this as 'still relevant' in case anyone is listening... :)

Like @ivanko2000, media resources recently became relevant to my interests/requirements as well.

We also have OData Services V4 running, and cannot integrate former streaming. Waiting for the implementation of streaming support in OData V4, please implement ASAP

I'm not sure if this is what they're after, but I do have streams working in my code: https://stackoverflow.com/a/48851615

@madansr7 please prioritize.

Any intention to release this yet ?
We are in year 4 since this was raised after all.

Would be very glad to hear if this issue will be fixed or not.

Was this page helpful?
0 / 5 - 0 ratings