IDataServiceStreamProvider.GetStreamContentType Method

Returns the content-type of the media resource that belongs to the specified entity.

Namespace:  System.Data.Services.Providers
Assembly:  Microsoft.Data.Services (in Microsoft.Data.Services.dll)

string GetStreamContentType(
	Object entity,
	DataServiceOperationContext operationContext


Type: System.Object
The entity that is a media link entry with a related media resource.
Type: System.Data.Services.DataServiceOperationContext
The DataServiceOperationContext instance used by the data service to process the request.

Return Value

Type: System.String
A valid MIME Content-Type value for the binary data.

This method is invoked by the data services framework to obtain the IANA content type (aka media type) of the stream associated with the specified entity. This metadata is needed when constructing the payload for the Media Link Entry associated with the stream (aka Media Resource) or setting the Content-Type HTTP response header. The string should be returned in a format which is directly usable as the value of an HTTP Content-Type response header. For example, if the stream represented a PNG image the return value would be "image/png" This method MUST always return a valid content type string. If null or string.empty is returned the data service framework will consider that an error case and return a 500 (Internal Server Error) to the client. NOTE: Altering properties on the operationContext parameter may corrupt the response from the data service.