Apex download file with file extension

1. Create procedure for download file
 procedure p_download_file(p_file_id number) is
   v_blob_length number;
   v_filename    varchar2(2000);
   v_blob_file   blob;
 begin
   -- clear apex headers
   sys.htp.init;
   -- get blob loength, file_name,extension
   select dbms_lob.getlength(rrt.file_blob)
         ,rrt.name || '.' || lower(rrt.extension)
         ,rrt.file_blob
     into v_blob_length
         ,v_filename
         ,v_blob_file
     from FILE_TABLE rrt
    where rrt.id = p_file_id;

   owa_util.mime_header('application/octet-stream', false);
   sys.htp.p('Content-lenght:' || v_blob_length);
   sys.htp.p('Content-disposition: attachment; filename="' || v_filename || '"');
   owa_util.http_header_close;
   wpg_docload.download_file(v_blob_file);
 end;


2. create process before header with condition so that process not always execute (REQUEST value)


3. Create Button "DOWNLOAD" and set to Submit page.
4. create branch that condition is when button pressed is "DOWNLOAD", with request value "DOWNLOAD_FILE" and redirect to the same page where is that process before header.

   

Comments

Post a Comment

Popular Posts