UploadProgressChanged Event Not Being Called (More Details)

旧街凉风 提交于 2020-01-06 05:57:06

问题


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?

来源:https://stackoverflow.com/questions/55300258/uploadprogresschanged-event-not-being-called-more-details

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!