问题
This question is exact duplicate of this one: UploadProgressChanged Event Not Being Called
Some more details:
- I am using Unity 2018.2.13f1
- The API is a POST method
- Video attachment is here
- Code sample:
void Upload(string url, string filePath)
{
WebClient webClient = new WebClient();
var authorizationHeaderValue = "Bearer: " + token;
webClient.Headers.Add("Authorization", authorizationHeaderValue);
webClient.UploadProgressChanged += new UploadProgressChangedEventHandler(WebClientUploadProgressChanged);
webClient.UploadFileCompleted += WebClientUploadCompleted;
webClient.UploadFileAsync(new System.Uri(url), filePath);
}
void WebClientUploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
{
Debug.Log("Upload {0}% complete. " + e.ProgressPercentage);
}
void WebClientUploadCompleted(object sender, UploadFileCompletedEventArgs e)
{
string reply = System.Text.Encoding.UTF8.GetString(e.Result);
Debug.Log(reply);
}
The original question was asked 6 years back, and it still doesn't have a solution. Anyone has a workaround?
来源:https://stackoverflow.com/questions/55300258/uploadprogresschanged-event-not-being-called-more-details