0 Replies Latest reply on Dec 19, 2017 7:10 AM by Scott Wesley

    Deliver .msg using bfilename() as web service

    Scott Wesley

      G'day all,

       

      I've used the following download style for documents for some time, using wpg_docload.download_file

      Download blob from function instead table field

      Note this example includes content-disposition, which means .msg files are opened with the email client, and download an unnamed file with no extension.

       

      During regression testing for 5.1, the function no longer appeared to be authenticated. I'm not sure if this is a missing configuration for the 5.1 instance, or a change to 5.1/ORDS.

      I suspect a little bit of both, but I'm yet to re-discover details on this.

      Edit: I was reading Joel's post yesterday, but I'm yet to confirm the ORDS setting on the 5.1 instance.

       

      Instead, I thought I could replace this style of function with a REST web service, using the media resource handler.

      The function serving blobs was easily translated into a simple query

       

      select mime_type
             ,the_blob
      from images
      where id = :id
      

       

      The other that served documents fetched using BFILENAME also worked fine, once I converted the function to return an object.

      It delivers PDF, images, etc with no problem.

       

      CREATE TYPE doc_obj AS OBJECT (
         id           number
        ,filename     varchar2(50)
        ,mime_type    varchar2(50)
        ,document     blob
      );
      /
      
      CREATE TYPE doc_obj_tab IS TABLE OF doc_obj;
      /
      
      create or replace function get_document
        (p_id  in  number)
        return doc_obj_tab IS
        l_tab  doc_obj_tab := doc_obj_tab();
      ...
        l_tab.extend;
        l_tab(1) := doc_obj(p_id, lc_filename, lc_mime_type
                           ,get_bfilename(p_id)
                           );
        return l_tab;
      ...
      
      select mime_type, document
      from table(get_document(:id))
      

       

      However, when I attempt to download a .msg file, my Chrome browser downloads an anonymously named file, just like it did when I had the original download function without content-disposition.

      D4467AA58C404E91ABE7083130715E2847F264A08153F26189D29DFD1696359599F4D71C0C7C7EF4 (1)

      It's the message, but won't open with the email client nicely until I add a .msg extension.

       

      First choice - how might I adjust the table function to include the content disposition?

      Second option - how are client functions whitelisted in APEX 5.1, ORSD 3.0.10?

       

      Cheers,

       

      Scott