Sometime uploading asset could take a long time and it is useful to track the uploading progress. We provide HTTP uploading currently and in the next release, we will support UDP fast upload with our partner.
To track progress, we provide UploadProgressEventArgs which describe the status of an upload operation.
Code Snippet showed as below:
private void btn_Start_Click(object sender, EventArgs e)
mediaContext = new CloudMediaContext(accName, accKey);
mediaContext.Assets.OnUploadProgress += new EventHandler<UploadProgressEventArgs>(OnUploadProgress);
IAsset asset = mediaContext.Assets.Create(inputfile);
void OnUploadProgress(object sender, UploadProgressEventArgs e)
Console.WriteLine("Current file: " + e.CurrentFile);
Console.WriteLine(" Bytes sent: " + e.BytesSent);
Console.WriteLine(" Progress: " + (e.Progress/100).ToString("0%"));
I format e.Progress into a percentage showed above, because e.Progress gives a long decimal number without ‘%’. Meanwhile, you could check out more properties of this event handler here.