Show TOC

Enabling Media LinksLocate this document in the navigation structure

Media type is only supported for feed and entry. You should redefine the method DEFINE() of the model provider extension class generated by the SB to avail the media link functionality.

Go to the generated model provider extension class and redefine the DEFINE () method using the following code:

DATA:
        lo_entity_type        TYPE REF TO /iwbep/if_mgw_odata_entity_typ, 
        lo_property           TYPE REF TO /iwbep/if_mgw_odata_property.
 
  CALL METHOD super->define( ).
  lo_entity_type = model-
>get_entity_type( iv_entity_name = <SOURCE_ENTITY>). 
  lo_property = lo_entity_type-
>get_property( iv_property_name = <SOURCE_PROPERTY>). 
  lo_property->set_as_content_type( ). 
 

Where, SOURCE_ENTITY is the entity name of the source service which has a media type (HasStream = True) and SOURCE_PROPERTY is the property of SOURCE_ENTITY which has the content type information. For example, in the code given below, SOURCE_ENTITY is ‘Image’ which has “HasStream = True”. The property “MimeType” of entity Image provides the MIMETYPE of the content such as JPEG, GIF, PNG….

DATA:
        lo_entity_type        TYPE REF TO /iwbep/if_mgw_odata_entity_typ, 
        lo_property           TYPE REF TO /iwbep/if_mgw_odata_property.
 
  CALL METHOD super->define( ).
 
  lo_entity_type = model-
>get_entity_type( iv_entity_name = ‘Image’ ). 
  lo_property = lo_entity_type-
>get_property( iv_property_name = ‘MimeType’ ). 
  lo_property->set_as_content_type( ).