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;
   -- clear apex headers
   -- get blob loength, file_name,extension
   select dbms_lob.getlength(rrt.file_blob)
         ,rrt.name || '.' || lower(rrt.extension)
     into v_blob_length
     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 || '"');

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.



  1. what is 'FILE_TABLE' in above procedure code ???

    1. user table where BLOB (FILE) is stored.

  2. This comment has been removed by the author.


Post a Comment

Popular Posts