【发布时间】:2011-06-27 10:46:43
【问题描述】:
我使用以下方法将文档上传到共享点文档库。 但是,在执行查询时 - 得到以下错误: Message = "远程服务器返回错误:(400) Bad Request。"
文件失败超过 1mb,因此我通过 sharepoint UI 对其进行了测试,并成功上传了相同的文件。
有什么想法吗?是否可以通过流式传输文件而不是 1 个大文件块?有问题的文件只有 3mb 大小..
private ListItem UploadDocumentToSharePoint(RequestedDocumentFileInfo requestedDoc, ClientContext clientContext)
{
try
{
var uploadLocation = string.Format("{0}{1}/{2}", SiteUrl, Helpers.ListNames.RequestedDocuments,
Path.GetFileName(requestedDoc.DocumentWithFilePath));
//Get Document List
var documentslist = clientContext.Web.Lists.GetByTitle(Helpers.ListNames.RequestedDocuments);
var fileCreationInformation = new FileCreationInformation
{
Content = requestedDoc.ByteArray,
Overwrite = true,
Url = uploadLocation //Upload URL,
};
var uploadFile = documentslist.RootFolder.Files.Add(fileCreationInformation);
clientContext.Load(uploadFile);
clientContext.ExecuteQuery();
var item = uploadFile.ListItemAllFields;
item["Title"] = requestedDoc.FileNameParts.FileSubject;
item["FileLeafRef"] = requestedDoc.SharepointFileName;
item.Update();
}
catch (Exception exception)
{
throw new ApplicationException(exception.Message);
}
return GetDocument(requestedDoc.SharepointFileName + "." + requestedDoc.FileNameParts.Extention, clientContext);
}
编辑:我确实找到了关于我的问题的以下 ms 页面(这似乎与他们提出的问题相同)http://support.microsoft.com/kb/2529243 但似乎没有提供解决方案。
【问题讨论】:
标签: sharepoint c#-4.0 sharepoint-2010 c#-3.0