We are using the Microsoft.Http.dll to do a API to consume RESTful calsl from a Ruby on Rails server.
Everything is ok so far but now we need get the byte stream(or something like that) to do a progress bar in UI.
I've researched about the HttpClient class library reference I didn't have success, I guess due the fact the api is a beta...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Xml;
using System.IO;
using System.Reflection;
using System.Xml.Serialization;
using System.Net;
using Microsoft.Http;
//....
FileInfo file = new FileInfo(@filepath);
HttpContent hc = HttpContent.Create(file, "application/octet-stream");
HttpMultipartMimeForm hm = new HttpMultipartMimeForm();
hm.Add("Filename", file.Name);
hm.Add("uploaded_data", file.Name, hc);
string uri = "https://server/service";
HttpClient http = Session.Instance.AuthorizedHttpClient();
HttpResponseMessage rmsg = http.Post(uri, hm.CreateHttpContent());
The question is... can I get the data to do a progress bar using this code above? Or I need other API to do that?
I believe HttpClient doesn't have upload / download progress callback like WebClient does because HttpClient sends the request at once and gets the response at once. Probably you'll need to resort to WebClient to do this for the moment (see UploadProgressChanged event). http://msdn.microsoft.com/en-US/library/system.net.webclient_members(v=VS.80).aspx
None
0 Points
1 Post
Upload process using HttpClient (WCF REST Starter Kit Preview 2)
Jun 02, 2010 07:58 PM|Shairon|LINK
Hi Guys,
We are using the Microsoft.Http.dll to do a API to consume RESTful calsl from a Ruby on Rails server.
Everything is ok so far but now we need get the byte stream(or something like that) to do a progress bar in UI.
I've researched about the HttpClient class library reference I didn't have success, I guess due the fact the api is a beta...
The question is... can I get the data to do a progress bar using this code above? Or I need other API to do that?
Thanks in advance for any answer.
Member
40 Points
21 Posts
Re: Upload process using HttpClient (WCF REST Starter Kit Preview 2)
Jun 06, 2010 11:46 AM|derianto|LINK
Hi Shairon,
I believe HttpClient doesn't have upload / download progress callback like WebClient does because HttpClient sends the request at once and gets the response at once. Probably you'll need to resort to WebClient to do this for the moment (see UploadProgressChanged event).
http://msdn.microsoft.com/en-US/library/system.net.webclient_members(v=VS.80).aspx
Thanks,
Deri