Click here to Skip to main content
15,895,667 members

Uploading more than 4 MB file using Client object model

Revision 1
CSS
cant upload the file more than 3 MB to SharePoint Library using Client Object model.

Following is the two ways i tried.

Way 1:


C#
using (FileStream fs = new FileStream(strCurrentTempPath, FileMode.Open))
{                    SP.File.SaveBinaryDirect(ClientContextName,ServerRelativeUrl, FileStream, true);
}


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();



Exception:
400 Bad Request
Posted 7-Nov-12 20:20pm by sugumaran srinuvasan.