Last post Jun 06, 2010 11:46 AM by derianto
Jun 02, 2010 07:58 PM|Shairon|LINK
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...
FileInfo file = new FileInfo(@filepath);
HttpContent hc = HttpContent.Create(file, "application/octet-stream");
HttpMultipartMimeForm hm = new HttpMultipartMimeForm();
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?
Thanks in advance for any answer.
Jun 06, 2010 11:46 AM|derianto|LINK
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).