Skip to content

Latest commit

 

History

History
150 lines (93 loc) · 3.1 KB

oos_util_web.md

File metadata and controls

150 lines (93 loc) · 3.1 KB

OOS_UTIL_WEB

Constants

Name Code Description
gc_content_disposition_inline
gc_content_disposition_inline constant varchar2(20) := 'inline';
For downloading file and viewing inline
gc_content_disposition_attach
gc_content_disposition_attach constant varchar2(20) := 'attachment';
For downloading file as attachment

GET_MIME_TYPE Function

Returns the mime-type for a filename

Syntax

function get_mime_type(
  p_filename in varchar2)
  return oos_util_values.value%type

Parameters

Name Description
p_filename Filename
return mime-type

Example

select
  oos_util_web.get_mime_type('file.xls') xls,
  oos_util_web.get_mime_type('file.txt') txt,
  oos_util_web.get_mime_type('file.swf') swf
from dual;

XLS                        TXT          SWF
-------------------------- ------------ ------------------------------
application/vnd.ms-excel   text/plain   application/x-shockwave-flash

DOWNLOAD_FILE Procedure

Download file
Will call apex_application.stop_apex_engine if called from within an APEX application

Syntax

procedure download_file(
  p_filename in varchar2,
  p_mime_type in varchar2 default null,
  p_content_disposition in varchar2 default oos_util_web.gc_content_disposition_attach,
  p_cache_control in varchar2 default null,
  p_blob in blob
  )

Parameters

Name Description
p_filename Filename
p_mime_type mime-type of file. If null will be automatically resolved via p_filename
p_content_disposition inline or attachment
p_cache_control options to pass to the Cache-Control attribute. Examples include max-age=3600, no-cache, etc. See https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching?hl=en for examples
p_blob File to be downloaded

Example


oos_util_web.download_file(
  p_filename => 'my_file.zip',
  p_blob => l_file):

DOWNLOAD_FILE-1 Procedure

Download clob file

Notes:

  • See download_file (blob) for full documentation

Syntax

procedure download_file(
  p_filename in varchar2,
  p_mime_type in varchar2 default null,
  p_content_disposition in varchar2 default oos_util_web.gc_content_disposition_attach,
  p_cache_control in varchar2 default null,
  p_clob in clob)

Parameters

Name Description
p_filename
p_mime_type
p_content_disposition
p_cache_control See download_file (blob) for documentation
p_clob

Example

oos_util_web.download_file(
  p_filename => 'my_file.txt',
  p_clob => l_file):