GetResultStreamAt() public method

public GetResultStreamAt ( [ position ) : IInputStream
position [
return IInputStream
Exemplo n.º 1
0
        private async static Task<string> GetResponseMessage(UploadOperation uploadOperation)
        {
            ResponseInformation responseInformation = uploadOperation.GetResponseInformation();

            //uint contentLength = Convert.ToUInt32(responseInformation.Headers["Content-Length"]);

            uint contentLength = (uint)uploadOperation.Progress.BytesReceived;

            uint statusCode = responseInformation.StatusCode;

            IInputStream resultStreamAt = uploadOperation.GetResultStreamAt(0);

            IBuffer result = await resultStreamAt.ReadAsync(
                new Windows.Storage.Streams.Buffer(contentLength),
                contentLength,
                InputStreamOptions.None);

            Stream responseStream = result.AsStream();

            XDocument xDocument = XDocument.Load(responseStream);

            foreach (XElement xe in xDocument.Root.Descendants())
            {
                if (xe.Name.LocalName.Equals("Ok"))
                {
                    return "SUCCESS";
                }
                if (xe.Name.LocalName.Equals("Error"))
                {
                    return xe.Value;
                }
            }
            return "Unspecified error submiting video";
        }
Exemplo n.º 2
0
        private async Task UploadProgress(UploadOperation obj)
        {
            Debug.WriteLine(obj.Progress.BytesSent * 100 / obj.Progress.TotalBytesToSend);

            if (obj.Progress.HasResponseChanged)
            {
                var stream = obj.GetResultStreamAt(0);
                var reader = new StreamReader(stream.AsStreamForRead());
                var results = await reader.ReadToEndAsync();

                var image = JsonConvert.DeserializeObject<ImageResponse>(results);
                //<?xml version="1.0" encoding="utf-8"?><rsp stat="ok"><method>smugmug.images.upload</method><Image id="2125852928" Key="R6bnfnM" URL="http://photos.jenkinsfamily.com.au/Other/Nat/25253579_mbht3D#2125852928_R6bnfnM"/></rsp>

            }
        }