Example #1
0
        public async void WriteToStream(Stream outputStream, HttpContent content, TransportContext context)
        {
            try
            {

              var channelBinding=   context.GetChannelBinding(ChannelBindingKind.Endpoint);

                var buffer = new byte[65536];
                using (var video = File.Open(_filename, FileMode.Open, FileAccess.Read))
                {
                    var length = (int)video.Length;
                    var bytesRead = 1;
                    while (length > 0 && bytesRead > 0)
                    {
                        bytesRead = video.Read(buffer, 0, Math.Min(length, buffer.Length));
                        await outputStream.WriteAsync(buffer, 0, bytesRead);
                        length -= bytesRead;
                    }
                }
            }
            catch (HttpResponseException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            finally
            {
                outputStream.Close();
            }
        }
 public static ChannelBinding GetToken(TransportContext context)
 {
     ChannelBinding token = null;
     if (context != null)
     {
         token = context.GetChannelBinding(ChannelBindingKind.Endpoint);
     }
     return token;
 }