使用客户端对象模型上传超过4 MB的文件 [英] Uploading more than 4 MB file using Client object model
本文介绍了使用客户端对象模型上传超过4 MB的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
无法使用客户端对象模型将文件上传超过3 MB到SharePoint库.
以下是我尝试过的两种方法.
方式1:
Cant upload the file more than 3 MB to SharePoint Library using Client Object model.
Following is the two ways i tried.
Way 1:
using (FileStream fs = new FileStream(strCurrentTempPath, FileMode.Open))
{ SP.File.SaveBinaryDirect(ClientContextName,ServerRelativeUrl, FileStream, true);
}
方式2:
Way 2:
Microsoft.SharePoint.Client.File file = oWeb.GetFileByServerRelativeUrl(ServerRelativeUrl);
FileVersionCollection versions = file.Versions;
FileSaveBinaryInformation fsbi = new FileSaveBinaryInformation();
ClientContext ctx = new ClientContext(RootUrl);
byte[] binaryData =System.IO.File.ReadAllBytes(strCurrentTempPath);
fsbi.Content = binaryData;
file.SaveBinary(fsbi);
clientContext.Load(file);
clientContext.Load(versions);
clientContext.ExecuteQuery();
例外:
400错误的请求
Exception:
400 Bad Request
推荐答案
在您的web.config中,增加maxRequestLength.
In you web.config, increase the maxRequestLength.
<system.web>
<httpruntime maxrequestlength="1000000" executiontimeout="240" requestvalidationmode="2.0" />
</system.web>
这篇关于使用客户端对象模型上传超过4 MB的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文