Problem in Uploading the large files to SharePoint Library using a client object model RRS feed

  • Question

  • Hi,

    I am uploading a files from the local drive to sharepoint document library using a client object model.

    It is working only when the file size is small, if the document size is large then it is throwing an exception "The remote server returned an error: (400) Bad Request."

    I have written the follwing code to Upload the files.

    Any one please help me to resolve this issue.

    ClientContext clientContext = new ClientContext(siteUrl);
                        Web web = clientContext.Web;
                        SharePointClient.List list = clientContext.Web.Lists.GetByTitle(documentLibrary);
                        FileCreationInformation fileInfo = new FileCreationInformation();
                        fileInfo.Content = System.IO.File.ReadAllBytes(fileName);
                        fileInfo.Url = url;
                        fileInfo.Overwrite = true;
                        Microsoft.SharePoint.Client.File uploadFile = list.RootFolder.Files.Add(fileInfo);
                        ListItem item = uploadFile.ListItemAllFields;
                        CamlQuery query = new CamlQuery();
                        query.ViewXml = @"<View><Query><Where><Eq><FieldRef Name='BaseName' /><Value Type='Computed'>" + url + "</Value></Eq></Where></Query></View>";
                        ListItemCollection uploaded = list.GetItems(query);

    Thanks, Swaroop Vuppala

    Friday, July 20, 2012 11:13 AM


  • you are limited in the size you want to upload with the default settings.

    in order to upload bigger file size, you will need to change some settings.

    in powershell

    $ws = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
    $ws.ClientRequestServiceSettings.MaxReceivedMessageSize =  2147483647

    do an IIS reset afterwads.

    I had set also the 

    <httpRuntime maxRequestLength="2097151" /> 

    in the web.config, not sure if it useful ...

    My SharePoint Blog

    Friday, July 20, 2012 11:20 AM