0 Replies Latest reply on Mar 5, 2014 4:41 PM by bpoarnet

    Large file download in APEX RESTful web service is crashing the apex listener

    bpoarnet

      We are running APEX 4.2.2.00.11 and the apex listener version 2.0.5.287.04.27 on WebLogic 10.3.2.

       

      Does the apex listener buffer file downloads from RESTful web services in memory before sending them t
      o tge browser?  I suspect it does, which is in my opinion, a bug because it will not scale for large f
      iles.  Using the "wpg_docload.download_file" PL/SQL call directly in APEX will stream the file directly to the browser with no buffering.  That same procedure called from a RESTful web service apears to buffer the file in the memory of the APEX listener before streaming it to the browser.

       

      Is this true, and if so is there a way around it?

       

      The basic PL/SQL code for doing a file download, when called from an APEX application process works great for any file size:

       

        owa_util.mime_header(NVL(v_mime,'application/octet'), FALSE);

        htp.p('Content-length: ' || v_length);

        htp.p('Content-Disposition:  ' || :G_ETD_SUB_DOC_DOWNLOAD_TYPE || '; filename="' || v_document_name || '"');

        owa_util.http_header_close;

        wpg_docload.download_file(v_contents);

       

      But this same code in a RESTful web service is much slower for large files, and overflows the memory of the APEX listener JVM for really large files. Doing a simple "Media Resource" download from a RWS has the same behavior for extremely large BLOBs too, so I doubt the PL/SQL is at fault.

       

      Thanks.

      Brian Powell

      Ohio Technology Consortium