HttpWebRequest上传进度 [英] HttpWebRequest Upload Progress

查看:97
本文介绍了HttpWebRequest上传进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以块的形式上传文件以跟踪进度。目前它正确迭代,但我不知道如何构建它以等待响应。现在,当我关闭
流时,它会立即跳转到文件大小0到100%然后上传。 Flushing在流上不起作用,我无法关闭它,因为我正在尝试继续写入它。 SendChunked = true,我不知道我的回答应该是什么。我实际上应该发送一些数据,关闭它,获取另一个请求
流,上传更多,等待响应,获得响应,然后重复?我认为这是非常低效的。 

I am trying to upload a file in chunks so as to track progress. Currently it iterates correctly, but I don't know how to structure it to wait for a response. Right now, It is jumping to the file size, 0 - 100% immediately and THEN uploading when I close the stream. Flushing doesn't work on the stream, and I can't close it because I'm trying to continue to write to it. SendChunked = true, and I don't know what my response is supposed to be. Am I actually supposed to send some data, close it, get another request stream, upload more, wait for a response, get response, and then repeat? I think this is extremely inefficient. 

推荐答案

可能: oWebrequest.AllowWriteStreamBuffering =
false ;

Maybe: oWebrequest.AllowWriteStreamBuffering = false;

参见eg  http://blogs.msdn.com/b/johan /archive/2006/11/15/are-you-getting-outofmemoryexceptions-when-uploading-large-files.aspx   (( http://stackoverflow.com/questions/4388689/vb-net-httpwebrequest-fileupload ))

See e.g. http://blogs.msdn.com/b/johan/archive/2006/11/15/are-you-getting-outofmemoryexceptions-when-uploading-large-files.aspx ((http://stackoverflow.com/questions/4388689/vb-net-httpwebrequest-fileupload))

稍后:此博客涵盖了您的场景

http://blogs.msdn.com/ b /延迟/存档/ 2009/09/08 / WH en-framework-designers-outsmart-yourself-how-to-perform-streaming-http-uploads-with-net.aspx

(你的第二个想法不是你所需要的,正如你所怀疑的那样。: - ) 你只需要使用一个HTTP请求。 这是除非服务器知道要拼凑所有从
不同操作中的位到某种方式......)

 


这篇关于HttpWebRequest上传进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆