最大文件上传大小在sharepoint [英] maximum file upload size in sharepoint
问题描述
我使用以下方法将文档上传到sharepoint文档库中。
然而,在执行查询时,得到以下错误:
Message =远程服务器返回错误:(400)错误请求。
I use the following method to upload a document into sharepoint document library. However, upon executing the query - get the following error: Message = "The remote server returned an error: (400) Bad Request."
文件失败1mb,所以我通过sharepoint UI和同一个文件上传成功。
the files are failing over 1mb, so i tested it via the sharepoint UI and the same file uploaded successfully.
任何想法的问题是什么?是否可能流文件而不是1大文件块?
any thoughts on what's the issue is? is it possible to stream the file over rather than 1 large file chunk? the file in question is only 3mb in size..
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 ,但似乎没有提供解决方案。
i did find the following ms page regarding my issue (which seems identical to the issue they have raised) http://support.microsoft.com/kb/2529243 but appears to not provide a solution.
推荐答案
ok在这里找到了解决方案:
http:// blogs .msdn.com / b / sridhara / archive / 2010/03/12 / uploading-files-using-client-object-in-share-share-2010.aspx
ok found the solution here: http://blogs.msdn.com/b/sridhara/archive/2010/03/12/uploading-files-using-client-object-model-in-sharepoint-2010.aspx
我需要将文档存储在托管文件的服务器上,然后使用filestream上传过程,我在我的代码如下:
i'll need to store the document on the server hosting the file then using the filestream upload process i've done in my code below:
private ListItem UploadDocumentToSharePoint(RequestedDocumentFileInfo requestedDoc, ClientContext clientContext)
{
try
{
using(var fs = new FileStream(string.Format(@"C:\[myfilepath]\{0}", Path.GetFileName(requestedDoc.DocumentWithFilePath)), FileMode.Open))
{
File.SaveBinaryDirect(clientContext, string.Format("/{0}/{1}", Helpers.ListNames.RequestedDocuments, requestedDoc.FileName), fs, true);
}
}
catch (Exception exception)
{
throw new ApplicationException(exception.Message);
}
return GetDocument(requestedDoc.SharepointFileName + "." + requestedDoc.FileNameParts.Extention, clientContext);
}
这篇关于最大文件上传大小在sharepoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!