UploadProgressChanged Event Not Being Called (More

2019-08-17 18:44发布

This question is exact duplicate of this one: UploadProgressChanged Event Not Being Called

Some more details:

  1. I am using Unity 2018.2.13f1
  2. The API is a POST method
  3. Video attachment is here
  4. 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?

0条回答
登录 后发表回答