2.2.6.3.14 Named Resource Streams

When an EntityType includes named resource streams, any representations of whole EntityType instances MUST include named resource stream instances by using the grammar listed in this section. The grammar rule "namedStreamInVJson" specifies how a named resource stream instance is represented. This rule is referenced, in turn, by the rule "entityPropertyInVJson" that specifies how EntityType instance members MUST be represented when representing an EntityType instance in Verbose JSON. See Entity Type (as a JSON object) (section 2.2.6.3.3) for more information on how EntityType instances are represented in Verbose JSON.

  
  
 namedStreamInVJson = quotation-mark entityNamedStream quotation-mark
                     name-seperator
                     entityNamedStreamInVJson
  
 entityNamedStreamInVJson = begin-object mediaResourceNVP end-object
  
 mediaResourceNVP =  quotation-mark "__mediaresource" quotation-mark
                     name-seperator
                     begin-object
                     mleMetadata
                     [value-seperator etagNVP]
                     end-object
                     ; defined in section 2.2.6.3.3 
  
 mleMetadata      =  
                     mediaSrcNVP 
                     value-seperator contentTypeNVP
                     [value-seperator editMediaNVP]
                     ; defined in section 2.2.6.3.3
  
 etagNVP          =  quotation-mark "media_etag" quotation-mark
                     name-seperator
                     quotation-mark entityTag quotation-mark
                     ; defined in section 2.2.6.3.3
  
 editMediaNVP     =  quotation-mark "edit_media" quotation-mark
                     name-seperator
                     quotation-mark resourcePath quotation-mark
                     ; defined in section 2.2.6.3.3
  
 mediaSrcNVP      =  quotation-mark "media_src" quotation-mark
                     name-seperator
                     quotation-mark resourcePath quotation-mark
                     ; defined in section 2.2.6.3.3
  
 contentTypeNVP   =  quotation-mark "content_type" quotation-mark
                     name-seperator
                     quotation-mark contentType quotation-mark
                     ; defined in section 2.2.6.3.3
  
 entityNamedStream = ; see section 2.2.3.6.1.11   
 entityTypeProperty=;  see section 2.2.6.3.3   
  

When a named resource stream is present on the declaring EntityType and not excluded from the results explicitly by using $select, the named resource stream instance MUST be present in the Verbose JSON representation.

The "media_src" and "content_type" name/value pairs MUST be included.

The "edit_media" name/value pair MAY be included if the named resource stream instance can be updated.

The "media_etag" name/value pair MAY contain an ETag (ETag (section 2.2.5.4)). When the ETag is included, the value MUST be the value of the ETag for the named resource stream instance.

The value of the "edit_media" name/value pair MUST be a URI that can be used to replace the existing stream with a HTTP PUT request. The value of the "media_src" name/value pair MUST be a URI that can be used to retrieve the stream of bytes with a GET request.

The value of the "content_type" name/value pair MUST specify the content type of the binary stream (as specified in [RFC2616]) that is represented by the "edit_media" URI . If the "media_etag" name/value pair is present, the value MUST be the ETag (ETag (section 2.2.5.4)) value for the named resource stream retrieved from the "edit_media" URI.

 {
    "__metadata": { "uri": "Photos(1)",
                    "type": "SampleModel.Photo",
                  },
    "ID": 1,
    "Name": "Mount Fuji",
    "Thumbnail": {
         "__mediaresource": {
              "edit_media": " http://server/uploads/Thumbnail546.jpg ",
              "media_src": "http://server/Thumbnail546.jpeg ",
              "content-type": "img/jpeg",
              "media_etag": "####"
         }
    },
    "PrintReady": {
         "__mediaresource": {
              "edit_media": "Photos(1)/PrintReady",
              "media_src": "Photos(1)/PrintReady ",
              "content-type": "img/png",
         }
    }
 }

Listing: Entity with Named Resource Streams Formatted in Verbose JSON