Access files present on knime server from Generic Javascript node

Is there a way possible to read files present on KNIME server (like in a temporary folder/ some location on server) from Generic Javascript View Node?

I would like my workflow to write some files on server and read them using Javascript.

I would appreciate your response on this.
This query is important for our project.


it is not possible to directly access files on the server using the Generic JavaScript View, because it is always executed in a browser. The only way to do this, is to place the files to some location that is accessible from the web. In case of the WebPortal this is in the directory of the deployed KNIME Server application in Tomcat under the /VAADIN/ folder. This should be treated very carefully though and I wouldn't recommend it. The WebPortal uses this location to serve all static resources needed and it might also pose a security risk, if the WebPortal is accessible from the outside.
Of course you can also do this with writing your files to an arbitrary server, that is accessible from the web.

A better way to handle this, if this is possible for you, is to write the files into your server workflow repository using the knime:// protocol and subsequently reading those files with a regular File Reader. You can then process the files in a workflow and feed the processed data into the Generic JavaScript View.

Let me know if this works for you, or if you have any further questions.



Thank you for confirming this Christian.

I had tried writing to VAADIN/folder but like you said it has security issues, anyone with URL can access it. Not an option.

Issue is the json file I need to access is very huge and I get Java heap space error whenever I convert it to string and pass it as input table. So I would like to split this JSON file into small bits and read it in parts from genericJS node when necessary.

What about using KNIME's REST API for this?

Another query:
If we place some files under VAADIN/folder, they dissapear whenever server is restarted, but only KNIME's core js files will be present.

Is there a way to store these somewhere permanently and access them through KNIME generic JS node?

We need this as we dont want to access highchart's/ any other plugins through cdn.



yes it is possible to use the REST API for this if you place the files in the server repository.

You can use the links "knime:upload" and "knime:download" on the individual items which point to "PUT xxx:data" and "GET xxx:data" respectively. There is also documentation if you browse to ".../rest/v4/_profile/knime-server-doc-v4.xml"

I guess you can also use this approach to load JavaScript libraries. You can place them in the repository and use requireJS to dynamically load them using the REST API.
On our roadmap there is an item for better handling and registering of libraries in the Generic JavaScript View, but it is not scheduled for any release yet.


Worked, Thanks!