没有调用UploadProgressChanged事件(更多详细信息)

时间:2019-03-22 13:04:36

标签: c# unity3d file-upload webclient

此问题与该问题完全相同: UploadProgressChanged Event Not Being Called

更多详细信息:

  1. 我正在使用Unity 2018.2.13f1
  2. API是POST方法
  3. 视频附件为here
  4. 代码示例:
    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);
    }

最初的问题是6年前提出的,至今仍没有解决的办法。有人有解决方法吗?

0 个答案:

没有答案