开发者

C#: Webclient Assigning Chunk size when using AsyncUploadData

开发者 https://www.devze.com 2022-12-17 20:21 出处:网络
i am using Webclient to upload data using Async call to a server, WebClient webClient = new WebClient();

i am using Webclient to upload data using Async call to a server,

    WebClient webClient = new WebClient();
   webClient.UploadDataAsync(uri , "PUT", buffer, userToken);

i've attached DatauploadProgress and DatauploadCompleted Events to appropriate callback functions

        // Upload Date Progress
        webClient.UploadProgressChanged += new 
        开发者_如何学运维UploadProgressChangedEventHandler(UploadProgressCallback);

      // Upload Date Progress
     void UploadProgressCallback(object sender, UploadProgressChangedEventArgs e)
    {
        // Magic goes here 

    }

i am trying to assign chunck/partial file upload size, to make the Callback Function get called at chosen periodic times.

Note: i know i can use e.BytesSent to read the bytes sent when the callback function gets called, but that's not what i am trying to do.


You can't define that chunk size, as WebClient doesn't expose any property to handle that.

If you want to control that packet length, you'll need to transfer your file by custom code, i.e., by looping through your desired chunk size and, at server side, to implementa System.Web.IHttpHandler to rebuild your file in correct order.

0

精彩评论

暂无评论...
验证码 换一张
取 消