开发者

SOAP , getting progress of the uploaded Request while its uploading c#

开发者 https://www.devze.com 2022-12-18 15:43 出处:网络
Im trying to upload a file through a SOAP request , and it worked perfectly , but I couldnt get a progress for the uploaded amount of the 开发者_运维问答request .You could try sending the file up in \

Im trying to upload a file through a SOAP request , and it worked perfectly , but I couldnt get a progress for the uploaded amount of the 开发者_运维问答request .


You could try sending the file up in "chunks", like 1MB at a time rather than sending it all up at once? That way when each chunk completes, you'll be able to update the progress.


I can answer my question now,

Im not using SOAP anymore to upload my files in my solution, Im using HTTPWebRequest now,

1) yes im uploading my large files in chunks (each chuck is 1MB), 2) each chunk(1 MB) can give me progress each BufferSize (4 KB in my case);

so there is a big loop, foreach(Chunk in File) {} .

and inside the big loop there is another loop, as Im using HTTPWebRequest:

long buffer = 4096;
Stream stm = request.GetRequestStream();
while (remainingOfChunkWithReq != 0)
{
  stm.Write(buffer, 0, bytesRead);
  remainingOfChunkWithReq = remainingOfChunkWithReq - bytesRead;
  bytesRead = memoryStream.Read(buffer, 0, bytesSize);
  //Send Progress
}

then continue to send the request. and receive the response.

0

精彩评论

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