2.2.6.2.10 Named Resource Streams

An Entry Resource MAY include one or more named resource streams.

When a server responds to a client request to retrieve an Entry Resource that contains named resource streams, the server MUST include information about those named resource streams in the response. That metadata for each named resource stream instance MUST be represented inside atom atom:link elements.

The edit link for a named resource stream, if present, MUST be represented as a link element that has:

  • The rel attribute set to http://schemas.microsoft.com/ado/2007/08/dataservices/edit-media/ with the name of the named resource stream appended and the href attribute set to the edit link for the named resource stream.

  • The "type attribute set to the Content Type of the named resource stream.

  • The m:etag attribute, if present, set to the ETag (section 2.2.5.4) value for the named resource stream.

There MAY also be a link element for the named resource stream's self link. If this element is present, it MUST have:

  • The rel attribute set to http://schemas.microsoft.com/ado/2007/08/dataservices/mediaresource/ with the name of the named resource stream appended.

  • The title attribute set to the name of the named resource stream.

  • The href attribute set to the self link for the named resource stream.

  • The type attribute set to the Content Type of the named resource stream.

  • The m:etag attribute, if present, set to the ETag value for the named resource stream.

If the edit link and self link are the same for the named resource stream instance, the server MAY optimize payload size by excluding the self link atom:link element. In the absence of a self link atom:link element for the named resource stream, clients MUST assume that the self link and edit link are the same and that the href of the edit link atom:link element MAY be used instead.

Similarly, the server MAY expose the named resource stream instance as read-only by including only the self link. This would retrieve the stream and omit the edit link.

For example, the entry in the following listing indicates that:

  • The "Thumbnail" named resource stream might be retrieved from 'http://server/Thumbnail564.jpeg'.

  • The "Thumbnail" named resource stream might be updated at "http://server/uploads/Thumbnail564.jpeg".

  • The "Thumbnail" named resource stream has a Content Type of "image/jpeg".

  • The "PrintReady" named resource stream might be both retrieved and updated at the same URI, namely, "Photos(1)/PrintReady/$value".

     <entry>
               <category term="SampleModel.Photo"
                 scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
               <id>http://host/service.svc/Photos(1)</id>
               <title type="text" />
               <updated>2008-03-30T21:52:45Z</updated>
               <author>
                 <name />
               </author>
               <link rel="edit" title="Photos" href="Photos(1)" />
               <link    rel="http://schemas.microsoft.com/ado/2007/08/dataservices/mediaresource/Thumbnail"     
                 type="image/jpeg"
                 title="Thumbnail"
                 href="http://server/Thumbnail546.jpeg" />
               <link 
     rel="http://schemas.microsoft.com/ado/2007/08/dataservices/edit-media/Thumbnail" 
                 type="image/jpeg"
                 title="Thumbnail"
                 href=" http://server/uploads/Thumbnail546.jpeg" 
                 m:etag="####" />   
               <link 
     rel="http://schemas.microsoft.com/ado/2007/08/dataservices/edit-media/PrintReady" 
                 type="image/png"
                 title="PrintReady"
                 href="Photos(1)/PrintReady " />           
               <content type="application/xml">
                 <d:ID m:type="Edm.Int32">1</d:ID>
                 <d:Name m:type="Edm.String">Mount Fuji</d:Name>
               </content>
     </entry>
    

Listing: AtomPub Entry with Named Resource Stream links