我想通过rest api将一个大文件(1.4 GB)放到onedrive上。通过C#将大文件放到一个带有REST API的驱动器中#
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(myUri);
webRequest.Timeout = 12 * 60 * 60 * 1000;
webRequest.AllowAutoRedirect = true;
webRequest.ReadWriteTimeout = 12 * 60 * 60 * 1000;
webRequest.AllowReadStreamBuffering = false;
webRequest.AllowWriteStreamBuffering = false;
webRequest.SendChunked = true;
webRequest.KeepAlive = false;
webRequest.ProtocolVersion = HttpVersion.Version10;
webRequest.ServicePoint.ConnectionLimit = 1;
webRequest.ContinueTimeout = 12 * 60 * 60 * 1000;
webRequest.Method = "PUT";
using (Stream stream = webRequest.GetRequestStream())
{
stream.WriteTimeout = 12 * 60 * 60 * 1000;
writeToStream(stream);
stream.Flush();
stream.Close();
}
但在角落找寻200MB我收到我在网上搜索,发现了一些建议,以保持活动设置为false IOException异常(写入过程中的基础连接已关闭。意外错误)
,设置HttpVersion
和你所看到的ConnectionLimit
。
我试过用不同的设置,但它总是一样的。
由于内存消耗,我无法使用HttpClient
。
该代码适用于小文件。
感谢您的帮助。我们尝试使用sdk,但它不起作用。我们不再使用OneDrive。 – Chris 2014-09-30 12:32:19