title: Uploading large documents to FileNet Content Engine
body: <p><strong>Using FileNet Java API version 5.1.0.3</strong></p>
  
  <p>I am trying to upload big document to P8. I am reading file using FileInputStream and setting the input stream to  contentTransfer.setCaptureSource(file); I am getting OOM exception (complete stacktrace below). Looks like it trying to read whole document in heap memory but that not what I want, I want to stream the document to P8.</p>
  
  <p>Code</p>
  
  <pre><code>//Get CE Connetcion
  //Create Subject
  //Push Subject
  
  //Get Domain (domain)
  ObjectStore os = null;
  objectStoreName = "COS" 
  os = Factory.ObjectStore.fetchInstance(domain, objectStoreName, null); 
  
  
   //Get Folder
   Folder folder=null;
   folderName = ''/Sample";
  folder=Factory.Folder.fetchInstance(os, folderName, null); 
  
  
   //Get the File details
  InputStream file = ""; 
  String fileName = "";
  int fileSize = "";
  
  // Create Document
  
  String docClass = "dcumnet class name";
  Document doc = Factory.Document.createInstance(os, docClass); 
  if (file != null &amp;&amp; fileSize &gt; 0) {
                          ContentTransfer contentTransfer = Factory.ContentTransfer.createInstance();
                          contentTransfer.setCaptureSource(file);
                          contentElementList.add(contentTransfer);
                          doc.set_ContentElements(contentElementList);
                          contentTransfer.set_RetrievalName(fileName);                        
                          doc.set_MimeType(getMimetype(fileName));
                      }
  
  
  //Check-in the doc
  doc.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY,CheckinType.MAJOR_VERSION);                   
  //Get and put the doc properties
  String documentName =""
  Properties p = doc.getProperties();
  p.putValue("DocumentTitle","abcd");
  p.putValue("Name","Rakesh");
  p.putValue("Number","01234"); 
  
  
  doc.save(RefreshMode.REFRESH)
  </code></pre>
  
  <p>Can you please help, how to send bigger document as stream to P8?</p>
  
  <pre><code>Caused by: java.lang.OutOfMemoryError: Java heap space
      at weblogic.utils.io.UnsyncByteArrayOutputStream.resizeBuffer(UnsyncByteArrayOutputStream.java:59) ~[com.bea.core.utils_1.10.0.0.jar:1.10.0.0]
      at weblogic.utils.io.UnsyncByteArrayOutputStream.write(UnsyncByteArrayOutputStream.java:89) ~[com.bea.core.utils_1.10.0.0.jar:1.10.0.0]
      at com.filenet.apiimpl.wsi.MtomOutputStream.write(MtomOutputStream.java:39) ~[Jace.jar:dap501.003.019]
      at com.filenet.apiimpl.wsi.AttachmentHelperNst.spillAndClearAttachments(AttachmentHelperNst.java:137) ~[Jace.jar:dap501.003.019]
      at com.filenet.apiimpl.wsi.ServiceSessionNst.bCloseSoapEnvelopeAndWriteAttachments(ServiceSessionNst.java:262) ~[Jace.jar:dap501.003.019]
      at com.filenet.apiimpl.wsi.ServiceSessionNst.cReqRespPath(ServiceSessionNst.java:159) ~[Jace.jar:dap501.003.019]
      at com.filenet.apiimpl.wsi.ServiceSessionNst.executeChanges(ServiceSessionNst.java:71) ~[Jace.jar:dap501.003.019]
      at com.filenet.apiimpl.util.SessionHandle.executeChanges(SessionHandle.java:130) ~[Jace.jar:dap501.003.019]
      at com.filenet.apiimpl.core.Session.callExecuteChanges(Session.java:142) ~[Jace.jar:dap501.003.019]
      at com.filenet.apiimpl.core.Session.executeChanges(Session.java:525) ~[Jace.jar:dap501.003.019]
      at com.filenet.apiimpl.core.Session.executeChange(Session.java:816) ~[Jace.jar:dap501.003.019]
      at com.filenet.apiimpl.core.IndependentlyPersistableObjectImpl.save(IndependentlyPersistableObjectImpl.java:83) ~[Jace.jar:dap501.003.019]
  </code></pre>