开发者

Linking to a File in Oracle ApEx

I'm trying to create a report in Oracle ApEx that displays a开发者_C百科 list of files, and allows you to download them.

The files are being created by an external application and I have full control over where they are placed. Just now I am creating them in a subfolder of the ApEx images directory (C:\oracle\product\11.2.0\dbhome_1\apex\images). However, if I try to link to here, I just get a blank page - I've tried the #WORKSPACE_IMAGES# and #IMAGE_PREFIX# values as the link URL but it doesn't work.

There doesn't seem to be any way to automatically add a file to ApEx's flows_files.wwv_flow_file_objects$ table other than having an ApEx page do it (or upload it as a static file using the ApEx workspace). One thing I think might be possible is to manually insert a record into the table, but with the various IDs it requires this could be a minefield.

Has anyone else came across this problem? Linking to a file on any other webserver would be elementary, especially if it is placed under the document root.


Just to provide an answer to this in case anyone stumbles upon this question - I managed to resolve it by storing the files in the database as BLOB values. You can then set up ApEx to serve up these files by following the instructions here: http://download.oracle.com/docs/cd/E14373_01/appdev.32/e13363/up_dn_files.htm#CIHHEHCJ


If you use Apex Listener or ORDS (Oracle Rest Data Services) deployed in Tomcat, Apache or Glassfish. All you need to do is, first identify your context root (image folder or /i) in your application server.

Linking to a File in Oracle ApEx

Then create a folder like 'assets', after that copy all the assets you need to reference in your Apex Application.

In Apex, you have to reference these assets like '/i/assets/file-name.jpg'.

All of this is for avoiding the weird Legacy path ( HTML DB <---> Apex 4.2) wwv_flow_file_mgr.get_file?p_security_group_id=123456789&p_fname= when you add the static file in your DB either as a application file or workspace file. In Apex 5, you don't have this weird path, instead, you have a virtual path reference to a file.


#WORKSPACE_IMAGES# returns a string like

wwv_flow_file_mgr.get_file?p_security_group_id=123456789&p_fname=

and is therefore only applicable to files stored in the Apex file table WWV_FLOW_FILES.

#IMAGE_PREFIX# returns a string like /i/, and this can be used in links to download files stored in the Apex images folders. For example I can create a link like this:

<a href="#IMAGE_PREFIX#"javascript/apex_4_0.js">Download some JS</a>

and when I run the page and click on it I can open or download that file.

It's not recommended to store your own files under the Apex images folder, because they could be overwritten during Apex upgrades. Instead you can define your own logical directory e.g. /myfiles/ on the app server pointing to a different location and then reference that instead like this:

<a href="/myfiles/picture1.jpg">Download picture 1</a>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜