Download File From Custom Table Using Application Express XE...
ShellieMay 22 2006 — edited Nov 13 2009I promise this is my last question about the application that I am currently developing...if I can just get this piece of functionality to work then I should be done done done!...at least until the users want more functionality. ;=)
So with that said...I am fighting with the functionality in Application Express that allows you to upload/download files to a custom table....upload appears to work with no issue but the download piece is giving me fits!!! Please note that I am using XE Production and I keep encountering the problem where Internet Explorer tells me that I am not authorized to view this page...HTTP Error 403 - Forbidden.
I believe I have followed all of the instructions located within the following link...
http://download-west.oracle.com/docs/cd/B25329_01/doc/appdev.102/b25309/adm_wrkspc.htm#BEJDIJAH
I ran the following using SQL Command line (I was logged on as "system" when I ran it)....
alter session set current_schema=FLOWS_020100;
CREATE OR REPLACE function wwv_flow_epg_include_mod_local(
procedure_name in varchar2)
return boolean
is
begin
if upper(procedure_name) in (
'CLUTCH.DOWNLOAD_TRIBAL_KNOWLEDGE') then
return TRUE;
else
return FALSE;
end if;
end wwv_flow_epg_include_mod_local;
CLUTCH is my schema name and my procedure is called download_tribal_knowledge......as a reference here is the download_tribal_knowledge procedure....
CREATE OR REPLACE PROCEDURE download_tribal_knowledge(p_tk_file_id in number) AS
v_mime VARCHAR2(48);
v_length NUMBER;
v_file_name VARCHAR2(2000);
Lob_loc BLOB;
BEGIN
SELECT TK_FILE_MIME_TYPE,
TK_FILE_ATTACHMENT,
TK_FILE_NAME,
DBMS_LOB.GETLENGTH(TK_FILE_ATTACHMENT)
INTO v_mime,
Lob_loc,
v_file_name,
v_length
FROM TRIBAL_KNOWLEDGE
WHERE TK_FILE_ID = p_tk_file_id;
--
-- set up HTTP header
-- use an NVL around the mime type and if it is a null then set it to application/octect
-- application/octect may launch a download window from windows
owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
-- set the size so the browser knows how much to download
htp.p('Content-length: ' || v_length);
-- the filename will be used by the browser if the users does a save as
htp.p('Content-Disposition: attachment; filename="'||substr(v_file_name,instr(v_file_name,'/')+1)|| '"');
-- close the headers
owa_util.http_header_close;
-- download the BLOB
wpg_docload.download_file(Lob_loc);
end download_tribal_knowledge;
The only thing I do not really know if I have done or not is the instructions say that you must compile the function....
"After changing the source code of this function, alter the Oracle Application Express product schema (FLOWS_xxxxxx) and compile the function in that schema.
To alter the product schema, FLOWS_xxxxxx :
Log in to SQL Command Line (SQL*Plus) as SYS or SYSTEM.
Alter the product schema (FLOWS_xxxxxx) by entering the following command:
ALTER SESSION SET CURRENT_SCHEMA FLOWS_xxxxxx;
Compile the function wwv_flow_epg_include_local.sql."
I do not know how to "compile" this function...any ideas on how you compile a function? I am also curious if the instructions are correct because it says to compile the function called wwv_flow_epg_include_local.sql...this function is named differenctly from the one above (www_flow_epg_include_mod_local.sql). Am I missing anything else??? Seems like I must be close since I appear to be having a security issue? Why can I not download the document(s) that I have uploaded? Any insight would be greatly appreciated!!!!!
Best regards,
Shellie