C# 通过c使用RESTAPI将大文件放在一个驱动器上#

C# 通过c使用RESTAPI将大文件放在一个驱动器上#,c#,rest,put,onedrive,C#,Rest,Put,Onedrive,我想把一个大文件(1.4 gb)通过onedrive HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(myUri); webRequest.Timeout = 12 * 60 * 60 * 1000; webRequest.AllowAutoRedirect = true; webRequest.ReadWriteTimeout = 12 * 60 * 60 * 1000; webRequest.AllowReadStr

我想把一个大文件(1.4 gb)通过onedrive

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时,我收到一个IOException(底层连接已关闭。写入过程中出现意外错误)

我搜索了互联网,找到了一些建议,可以将KeepAlive设置为false,设置
HttpVersion
ConnectionLimit
,如您所见

我尝试过不同的设置,但总是一样的

由于内存消耗,我无法使用
HttpClient


该代码适用于小文件。

您是否尝试过使用LIVE SDK for windows runtime

希望有了这个,你可以实现,因为它提供了asyc上传


注意:这是离题的。但我还是想到了共享。我尝试过使用AWS SDK上传到Amazon S3,它确实有效,我尝试过使用大约800MB的文件。

目前无法通过REST API上传大于100MB的文件。希望这种情况在将来会有所改善。

OneDrive已经支持大文件上传了

感谢您提供的信息。OneDrive Api完全是垃圾。我们停止了OneDrive支持,将只使用Dropbox、Google Drive和Box。感谢您的帮助。我们尝试使用sdk,但它不起作用。我们将不再使用OneDrive。