title: Sharepoint 2013 Add large files with rest api
body: <p>I am working on a project to copy files from one document library to another in Sharepoint 2013 via jquery and the rest api.  My solution is based off of this <a href="http://techmikael.blogspot.com/2013/07/how-to-copy-files-between-sites-using.html" rel="nofollow">http://techmikael.blogspot.com/2013/07/how-to-copy-files-between-sites-using.html</a></p>
  
  <p>The following code works for smaller file sizes (64mb or less).  However I am getting an error when attempting to copy larger files (128Mb and up).  The addFileBinary function returns to the error callback with "Not enough storage is available to complete this operation."  Is there a workaround for this?  I am using IE11.</p>
  
  <pre><code>$(document).ready(function () 
  {
      //Get binary data of file to copy
      getFileBinary(fromUrl, FileServerRelativeUrl, function (binary) 
      {    
          //Copy binary file data to new library
          addFileBinary(toUrl, newLibraryName, FileName, binary, function (newFile) 
          {
              alert("File Added");
          },null);
  
      },null);
  }
  
  
  function getFileBinary(url, filePath, complete, failure) 
  {
      var executor = new SP.RequestExecutor(url);
      var info = {
          url: "_api/web/getfilebyserverrelativeurl('" + filePath + "')/$value",
          method: "GET",
          binaryStringResponseBody: true,
          success: function (data) {
              //binary data available in data.body
              complete(data.body);
          },
          error: function (err) {
              failure(err);
          }
      };
      executor.executeAsync(info);
  }
  
  function addFileBinary(url, libraryName, fileName, arrayBuffer, complete, failure) {
      var executor = new SP.RequestExecutor(url);
      var info = {
          url: "_api/web/GetFolderByServerRelativeUrl('" + libraryName + "')/Files/Add(url='" + fileName + "', overwrite=true)?$expand=ListItemAllFields,ListItemAllFields/ParentList",
          headers: {
              "Accept": "application/json; odata=verbose",
              "content-length": arrayBuffer.length,
          },
          method: "POST",
          contentType: "application/json;odata=verbose",
          binaryStringRequestBody: true,
          body: arrayBuffer,
          state: 'Update',
          success: function (data) {
              var jsonObj = $.parseJSON(data.body);
              complete(jsonObj.d);
          },
          error: function (err) {
              failure(err);
          }
      };
      executor.executeAsync(info);
  }
  </code></pre>
  
  <p>I have done the following to try to correct this issue  (None of it worked).</p>
  
  <ul>
  <li>Changed the general settings of the web app to allow files up to 2047. </li>
  <li>Increased the connection timeout setting in iis for Sharepoint.</li>
  <li>Added maxRequestLength="2096128" executionTimeout="999999" to httpruntime in the web.config </li>
  <li>Increased the maxAllowedContendLength in the web.config to 2147483647</li>
  </ul>