lotus domino - Xpages SSJS - Outputting files is slow for large files -


i trying output pdf files have on local filesystem of domino server using instructions steve wissel's page(s). http://www.wissel.net/blog/d6plinks/shwl-7mgfbn

the file downloaded, takes few minutes files in 20mb range. there way speed streaming?

    <?xml version="1.0" encoding="utf-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core" rendered="false">      <xp:this.beforerenderresponse><![cdata[#{javascript://importpackage(java.io.file); var excon = facescontext.getexternalcontext(); var response = excon.getresponse(); var out = response.getoutputstream();  if (out==null) {   print("the freakn' stream isn't there"); } else {   print("all stream"); }  try {   /*    * move existing code here...    */     print("setting headers");     response.setcontenttype("application/octet-stream");     response.setheader("content-disposition","attachment;filename=ebook.pdf");     response.setheader("cache-control", "no-cache");      var file:java.io.file = new java.io.file("c:\\autotrader\\r-gswob.pdf");      if (file.exists()) {         print("file exists");     } else {         print("file missing");     }     var filein:java.io.fileinputstream = new java.io.bufferedinputstream(new java.io.fileinputstream(file));     var c:int;     while ((c = filein.read()) != -1) {             out.write(c);     }  } catch (e) {   print("error generating dynamic pdf: " + e.tostring()); } {     if (filein != null) {             filein.close();     }     if (out != null) {             out.close();     }   facescontext.responsecomplete(); }   }]]></xp:this.beforerenderresponse></xp:view> 

use greater buffer 1 int value copy file:

var buffer = new byte[10000]; var len; while ((len = filein.read(buffer)) != -1) {         out.write(buffer, 0, len); } 

this speed download lot.


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -