Download files from database column (IJC web)

User d90f4e1cc8

11-10-2013 04:57:22

Hello,


We have report files in BLOB/CLOB columns in a database table. In IJC I managed to create a button with a groovy script to download the files for the current selected structure and store them to file system without showing the column on the client (it's available in the data tree).


Now I want to do something similar in IJC web.


What I tried already: I created an extra text field for the file content with a JavaScript to download the content. Unfortunately this works only for FireFox and Chrome, but our company standard browser (that users have to use) is IE9.


So I have some questions:


- Is it possible to fetch data from the data tree without showing them on the client?


- Is it possible to download files from database columns (the file name is visible in a table widget)?


- Maybe one workaround might be to create a Rest-Service to provide a server side download link, but how can I access such a link from IJC web?


 


Best regards,


Mike

ChemAxon 2bdd02d1e5

14-10-2013 14:06:15

Hi Mike,


We think that only solution satisfying your needs is to create a Rest-Service and provide the links. In IJC you can create URL field. This is what would be used to provide links in IJC Web.


To your other questions:
In fact, only displayed data are loaded by the client, it means that IJC Web and it's JavaScript can not fetch the data, which are not shown in the form.
Therefore it's currently not possible to download files stored as BLOB/CLOB data in DB. For this you would use that Groovy script, but there is no alternative in IJC Web Client.


What you tried, creation of file by using JavaScript seems like a serious security violation (from Browser point of view). Then it's possible that IE security settings did not allowed it. (Or is it using some non-standard hack?)


Best regards,


Filip

User d90f4e1cc8

15-10-2013 06:10:31

Hi Filip,


Thank you for your answer.


So I will create some REST service to solve the problem.


The JavaScript shouldn't be problematic, it's supported with IE>=10.


Here the part for FireFox/Chome (with html5 this look more compact, but the principle is the same):


                textFileAsBlob = new Blob([value[reportFileFieldId]], {type:'text/plain'});
                var fileNameToSaveAs = value[reportFileNameFieldId];
                var downloadLink = document.createElement("a");
                downloadLink.download = fileNameToSaveAs;
                downloadLink.innerHTML = "Download File";
                // Firefox requires the link to be added to the DOM
                // before it can be clicked.
                downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
                downloadLink.style.display = "none";
                document.body.appendChild(downloadLink);
                downloadLink.click();


 


Best regards,


 


Mike

ChemAxon 2bdd02d1e5

15-10-2013 07:48:15

Hi Mike,


You are welcome.


We plan to support downloading content of binary fields to files in future as a regular feature in web client. But we do not know when yet. For now, the REST service is the best choice.


Thanks for your understanding.


Filip

User d90f4e1cc8

15-10-2013 14:42:08

Hi Filip,


I created an URL field in IJC and put it into a text field and in a table column. In IJC web the URL field shows up as a link, but in the table the column is rendered as normal text.


Is it possible to render the table column as link?


 


Btw.: the email notification of changes doesn't work.


Best regards,


Mike

ChemAxon 2bdd02d1e5

16-10-2013 14:52:04

Hi Mike,


That's right. It's shown as a link in text field only. It's not possible to render links in table.
We will have a look at that issue.


Best regards,


Filip

ChemAxon 2bdd02d1e5

04-11-2013 22:16:20

We have it fixed, will be released in the version 6.2.