DataServiceContext.GetReadStream Method (Object, String)

Gets the binary data stream that belongs to the specified entity, by using the specified Content-Type message header.

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

public DataServiceStreamResponse GetReadStream(
	Object entity,
	string acceptContentType


Type: System.Object
The entity that has the binary data stream to retrieve.
Type: System.String
The Content-Type of the binary data stream requested from the data service, specified in the Accept header.

Return Value

Type: System.Data.Services.Client.DataServiceStreamResponse
An instance of DataServiceStreamResponse that represents the response.


entity is null.


acceptContentType is null.


The entity is not tracked by this DataServiceContext.


The entity is in the Added state.


The entity is not a Media Link Entry and does not have a related stream.

The acceptContentType parameter should be a valid Content-Type value for the Accept HTTP header.

The GetReadStream method synchronously requests the related binary data stream for the entity.

In the AtomPub protocol, the entity is a Media Link Entry and the binary stream is the associated Media Resource.

No validation is performed on the headers that are set in acceptContentType. Therefore, do not change this HTTP header in a way that changes the meaning of the request.