Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Upload byte array to server with progress percentages in Xamarin.Forms

$
0
0

I am trying to upload a byte array from Xamarin.Forms application using HttpClient. So far it's getting uploaded but I am not able to get upload progress. Is there any way to get an upload progress in percentage while file is being uploaded to server?

Here is a code snippet I am using for byte array upload.

var bytearray = videoData;
var uploadRequestBody = new ByteArrayContent(bytearray, 0, bytearray.Length);
uploadRequestBody.Headers.ContentLength = bytearray.Length;
uploadRequestBody.Headers.ContentType = new 
MediaTypeWithQualityHeaderValue("video/mp4");
HttpClient uploadRequestClient = new HttpClient();
uploadRequestClient.Timeout = TimeSpan.FromMinutes(60);
var uploadRequest = new HttpRequestMessage(HttpMethod.Put, <Some URL Endpoint>);
uploadRequest.Content = uploadRequestBody;
var uploadResponse = await uploadRequestClient.SendAsync(uploadRequest);
var uploadResponseResult = uploadResponse.Content.ReadAsStringAsync().Result;

Thanks in advance.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>