Export (0) Print
Expand All

IDataServiceStreamProvider.GetWriteStream Method

Returns the stream that the data service uses to write the binary data for the media resource received from the client that belongs to the specified entity.

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

Stream GetWriteStream(
	Object entity,
	string etag,
	Nullable<bool> checkETagForEquality,
	DataServiceOperationContext operationContext


Type: System.Object
The entity that is a media link entry with a related media resource.
Type: System.String
The eTag value that is sent as part of the HTTP request that is sent to the data service.
Type: System.Nullable<Boolean>
A nullable Boolean value that determines what kind of conditional request was issued to the data service, which is true when the eTag was sent in an If-Match header, false when the eTag was sent in an If-None-Match header, and null when the request was not conditional and no eTag was included in the request.
Type: System.Data.Services.DataServiceOperationContext
The DataServiceOperationContext instance that is used by the data service to process the request.

Return Value

Type: System.IO.Stream
A valid Stream the data service uses to write the contents of a binary data received from the client.

This method is invoked by the data services framework whenever an insert or update operation is being processed for the stream associated with the entity instance specified via the entity parameter. Notes to Interface Implementers The operationContext argument is passed as it is likely that an implementer of this interface method will need information from the HTTP request headers in order to construct a write stream. Likely header values required are: 'Content-Type' 'Content-Disposition' 'Slug' (as specified in the AtomPub RFC 5023) An implementer of this method MUST perform concurrency checks as needed in their implementation of this method. If an If-Match or If-None-Match request header was included in the request, then the etag parameter will be non null, which indicates this method MUST perform the appropriate concurrency check. If the concurrency check passes, this method should return the requested stream. If the concurrency checks fails, the method should throw a DataServiceException with the appropriate HTTP response code as defined in HTTP RFC 2616 section 14.24 and section 14.26. If the etag was sent as the value of an If-Match request header, the value of the ‘checkETagForEquality’ header will be set to true If the etag was sent as the value of an If-None-Match request header, the value of the ‘checkETagForEquality’ header will be set to false An implementer of this method MUST NOT set the following HTTP response headers on the operationContext parameter as they are set by the data service runtime: Content-Type ETag An implementer of this method may set HTTP response headers (other than those forbidden above) on the operationContext parameter. An implementer of this method should only set the properties on the operationContext parameter which it requires to be set for a successful response. Altering other properties on the operationContext parameter may corrupt the response from the data service. Stream Ownership The data service framework will dispose the stream once all bytes have been successfully written to the stream. If an error occurs while writing to the stream, then the data services framework will generate an error response to the client as per the "error contract" semantics followed by V1 data services

© 2014 Microsoft