File Download on Business Hub

Hello,
I have a question about file downloads within a app. We are using AP 5.2.3 and the latest Business Hub version.
I am using a Python Script to create an Excel file which i would like to offer to the consumer as a download. The file is saved in a temp dir and the link will be provided via a download widget.
So far, so good. It is working fine locally in Analytics Platfrom (output is a absolute path (C:.…) but not on Business Hub. Here the created temp file path looks like this:
“/tmp/tmpc5m3tsuv\filenname.xlsx”.
I have tried various options with tempfile in Python and with “Create Temp Folder” node. Both resulting in the similar problem. The created folder could not be handled and the file will not be saved
Any idea how to solve this in a smart way?
many thanks in advance!
Lars

Hello @larsgrohmann ,

in general downloading file from the Business Hub should work. Somehow :slight_smile:
The file path that you shared looks like a bit strange, suspicious, though:
/tmp/tmpc5m3tsuv\filenname.xlsx
It contains backslash (Windows) and forward slashes (Linux) in the same time.
Are you sure your python script is correct?
Would it be possible to share the script, the part of the workflow that you are using, for testing this?

I’m not very familiar with python scripts but found that documentation:
https://knime-python.readthedocs.io/en/stable/script-api.html#utility-functions
Maybe the utility functions there can help you to get the correct file path?

Cheers

1 Like

I’m having a similar (possibly the same) problem: the Create Temp Folder node can’t write to the local file system, in order to create a folder. I tried using a relative path to the workflows data area, which appeared to work except that my download link failed to resolve - Chrome said the file wasn’t on the server.

Could you please point us towards some docs on how file writers and the Create Temp Folder node should be configured for use in a deployed Data App?

Hello @rsherhod ,

Would this post be a solution for your use case?

Cheers,

Hi,
Sorry for my late reply!
For sure i am not sure. :wink:

Here is the code (part)

Create a temporary directory

temp_dir = tempfile.mkdtemp()
file_name = flow_variables[‘output_file_name’]

Define the file path

output_data_path = f"{temp_dir}{file_name}"

You are right. Mixing up slashes in Win and Linux could be the reason. on local Analytics Platform it is all Windows and works well.
Maybe i have to rework that it is working for both.
Many thanks,
Lars

Hi,
sounds like a promising alternative. I will give it a try.
Many thanks

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.