Maximum file upload size in sharepoint

I use the following method to upload a document to the sharepoint document library. However, after executing the request, you will receive the following error: Message = "The remote server responded to the error: (400)" Bad request ".

files fail more than 1 mb, so I tested it through the sharepoint user interface and the same file that was downloaded successfully.

any thoughts on what the problem is? Is it possible to transfer a stream over more than 1 large fragment of a file? This file is only 3 MB 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); } 

EDIT: I found the following ms page regarding my problem (which seems to be identical to the problem they raised) http://support.microsoft.com/kb/2529243 , but there is no way to provide a solution.

+2
source share
1 answer

ok found a solution here: http://blogs.msdn.com/b/sridhara/archive/2010/03/12/uploading-files-using-client-object-model-in-sharepoint-2010.aspx

I will need to save the document on the server where the file is located, and then using the upload process of the download file, which I did 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); } 
+2
source

Source: https://habr.com/ru/post/1434816/


All Articles