public Stream GetPhotoWriteStream(StreamingServicePhotoBase photo, string contentType) { PhotoWriteStream stream = new PhotoWriteStream(photo, contentType); this.pendingChanges.Add(new PendingChange() { ChangeType = ChangeType.UpdateStream, List = null, Resource = stream }); return(stream); }
public System.IO.Stream GetWriteStream(object entity, string etag, bool?checkETagForEquality, DataServiceOperationContext operationContext) { if (operationContext.RequestHeaders["Content-Type"] == "test/fail-this-request") { throw new InvalidOperationException("Request failed for test reasons."); } StreamingServicePhotoBase photo = entity as StreamingServicePhotoBase; if (photo == null) { throw new ArgumentException("The specified entity is not a photo entity.", "entity"); } return(((StreamingServiceContext)this.CurrentDataSource).GetPhotoWriteStream(photo, operationContext.RequestHeaders["Content-Type"])); }
public string GetStreamContentType(object entity, DataServiceOperationContext operationContext) { StreamingServiceRequestHeaders headers = entity as StreamingServiceRequestHeaders; if (headers != null) { return("text/plain"); } StreamingServicePhotoBase photo = entity as StreamingServicePhotoBase; if (photo == null) { throw new ArgumentException("The specified entity is not a photo entity.", "entity"); } return(photo.GetContentType()); }
public Uri GetReadStreamUri(object entity, DataServiceOperationContext operationContext) { StreamingServiceRequestHeaders headers = entity as StreamingServiceRequestHeaders; if (headers == null) { StreamingServicePhotoBase photo = entity as StreamingServicePhotoBase; if (photo == null) { throw new ArgumentException("The specified entity is not a photo entity.", "entity"); } StreamingServicePhoto photoV2 = photo as StreamingServicePhoto; if (photoV2 != null && photoV2.AlternativeUri && contentServiceUri != null) { return(new Uri(contentServiceUri.ToString() + "PhotoContent?id=" + photoV2.ID.ToString(), UriKind.Absolute)); } } return(null); }
public System.IO.Stream GetReadStream(object entity, string etag, bool?checkETagForEquality, DataServiceOperationContext operationContext) { if (GetReadStreamOverride != null) { return(GetReadStreamOverride(entity, etag, checkETagForEquality, operationContext)); } StreamingServiceRequestHeaders headers = entity as StreamingServiceRequestHeaders; if (headers != null) { return(new MemoryStream(Encoding.UTF8.GetBytes(headers.Headers.ToString()))); } StreamingServicePhotoBase photo = entity as StreamingServicePhotoBase; if (photo == null) { throw new ArgumentException("The specified entity is not a photo entity.", "entity"); } return(new MemoryStream(photo.GetContent())); }
public PhotoWriteStream(StreamingServicePhotoBase photo, string contentType) { this.photo = photo; this.stream = new MemoryStream(); this.contentType = contentType; }