can you please give a bit more context how and where you call wpg_docload.download_file? Do you have this issue with a migrated application or a new one?
One difference between 4.0 and later is that we now write http headers (e.g. cache-control) and the headers might not be closed when running the before header processes. It might help if you put htp.init or maybe even htp.p('') before the call to wpg_docload.download_file, but we need more information to give proper advice.
thanks for your fast answer. The issue is with a migrated application.
And here is snippet of my package code:
l_filename := r_brief.template_naam;
l_mime_type := r_brief.template_mime;
v_document_clob := GEN$PL_UTILS.blob_to_clob(r_brief.template_blob);
v_document_clob := GEN$PL_UTILS.replace_tags_in_clob(v_document_clob , tab_temp_tags_values, tab_temp_toegelaten_tags, v_replace_error);
l_doc := GEN$PL_UTILS.clob_to_blob(v_document_clob);
l_length := DBMS_LOB.getlength(l_doc);
HTP.p ('Content-length: ' || l_length);
HTP.p ('Content-Disposition: attachment; filename="'||REPLACE(REPLACE(SUBSTR(l_filename,INSTR(l_filename,'/')+1),CHR(10),NULL),CHR(13),NULL)||'"');
Do you see something wrong here?
Yes, already tried that and doesn't help me. No errors or something, the last line of debugging is this one: A C C E P T: Request="Open brief1"
which imo tells the my procedure is accepted to execute. But it doesn't go further than that and doesn't execute anything.
I would suggest to debug your plsql block and see if there are any issues.
Also try downloading a simple blob directly without additional calls to your local sub programs and see if that works!
I debugged my pl sql block and tried reaching my blob directly without sub procedures or something but nothing. It doesn't show any errors and doesn't execute anything. Is there something that changed from 4.0 to 4.2.1 that can cause any of this problems?
You mention your code runs after you press the button.
Are you branching to a page who's only job is to serve the attachment?
Or is this code inside a process that runs as part of the same page?
Are you able to confirm that there's something to download on the clob coming back from GEN$PL_UTILS.blob_to_clob ?
Perhaps set a debug message with that size of it?
After the wpg_docdownload, do you stop APEX processing, with for example "apex_application.stop_apex_engine;"?
I know, I know, lots of questions, but this seems like an odd problem to have,
Sorry for the late answer, couldn't go online due to personal reasons, but i will try to answer all your questions.
-Are you branching to a page who's only job is to serve the attachment?
--> There are different processes on the page (update data (button "update")/open different RTF files depending on which button you press) so this is code inside a process on that page that runs as part of that page.
-Are you able to confirm that there's something to download on the clob coming back from GEN$PL_UTILS.blob_to_clob ?
Perhaps set a debug message with that size of it?
--> the function GEN$PL_UTILS.blob_to_clob works perfect and always worked in the past in APEX 4.0 until the APEX 4.2.1 migration. So I don't there is something wrong with this.
- After the wpg_docdownload, do you stop APEX processing, with for example "apex_application.stop_apex_engine;"?
--> no i don't. My last code line is: WPG_DOCLOAD.download_file (l_doc); do I need to put that command as my last line?
Yes, you need to call apex_application.stop_apex_engine. It will stop the processing and prevent sending any other info to the http buffer. Downloading the document should really be the only process for that button's action (aside from necessary previous process then, if any).
Just put this line of code after my download line like this:
But didn't solve the problem. still doesn't open my RTF.
did you already try to put
before wpg_docload.download_file? For these kinds of issues, I would also try to analyze the HTTP response with Firebug, the Chrome dev tools or Wireshark.
tried htp.init; before wpg_download... but didn't do it.
used Firebug before and tried it again and got this as result. Don't know if you see something strange?
1 person found this helpful
the HTTP response shows
i.e. a redirect and
which means the response was ca. 40k long. A normal redirect response is way shorter. The htp.init should remove any output prior to download_file and the stop_apex_engine should ensure that no output happens after the call. It leaves me puzzled what's going on in your application. Maybe it's easy to spot the problem when having access to the app. Can you install the app (or at least the relevant parts) in a workspace on apex.oracle.com?
Sorry, pressed a button where the htp.init and apex_application.stop_apex_engine where not used. Tried it again where the 2 command lines were used, and used firebug again.
Now the Content-Length : 0;
I don't know if I can install the application on the apex.oracle.com workspace. Have to ask here because it's a very large application of the Belgian Government with important data and complex authorization scheme. I see if I can do something.