2014-09-29 49 views
0

我想通过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

该代码适用于小文件。

回答

0

您是否使用过LIVE SDK for windows runtime?

http://msdn.microsoft.com/en-us/library/dn659730.aspx http://msdn.microsoft.com/en-us/library/windows/apps/hh826531.aspx

希望这一点,就可以实现的,因为它提供了ASYC上传。

注:这是题外话。但我仍然想到分享。我尝试使用AWS SDK上传到Amazon S3,它确实有效,并且我尝试了大约800MB的文件。

+0

感谢您的帮助。我们尝试使用sdk,但它不起作用。我们不再使用OneDrive。 – Chris 2014-09-30 12:32:19

0

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

+0

感谢您的信息。 OneDrive Api完全是废话。我们采用了OneDrive支持,并且只会使用Dropbox,Google Drive和Box。 – Chris 2014-09-30 12:31:07

相关问题