Hello, I am trying to upload a photo to a sharepoint library. If I use a relatively small file (370KB) then it works without any problems. But if I try to upload a file that is about 3MB large then I get the error: "Der Remoteserver hat einen Fehler zurückgegeben: NotFound." translated: "The remote server returned an error: NotFound."
I read that it should be possible to set the max message size, but I found no way to set such a thing in the ClientContext object.
This is the code I use:
private void UploadFileCallback(object state)
{
var args = (List<object>)state;
var itemContainer = (ISharepointItemContainer)args.ElementAt(0);
var fileInfo = (FileInfo)args.ElementAt(1);
var sharepointList = _context.Web.Lists.GetByTitle(itemContainer.ListName);
Microsoft.SharePoint.Client.File uploadFile;
FileCreationInformation newFile;
using (FileStream fs = fileInfo.OpenRead())
{
byte[] content = new byte[fs.Length];
newFile = new FileCreationInformation();
int dummy = fs.Read(content, 0, (int)fs.Length);
newFile.Content = content;
newFile.Url = itemContainer.AbsoluteUrl + "/" + fileInfo.Name;
uploadFile = sharepointList.RootFolder.Files.Add(newFile);
_context.Load(uploadFile);
}
_context.ExecuteQuery();
if (FileUploadCompleted != null)
{
FileUploadCompleted(this, EventArgs.Empty);
}
}
Does anyone have an idea on how to resolve this issue?