automising number of download nodes

Hi all,

if my server worflow is creating an unknown number of files and I want to allow to download those files individually (not via big zip) on one page of the webservice, how can I achive that without setting up a huge amount of brunches with download nodes and inactivating them if not used?

I played with the parallel chunk nodes which do create automatically the exact number of nodes I need, but that dosn’t work in a component as expected. Is there nowadays an easy solution available for such cases?

Many thanks in advance
Lars

Hi @laval , can you show us what you have in the component? And do you get any errors? If so, please share what the error messages are

1 Like

Hi Bruno,

in essence the component node contains one download node. And if I try to use the chunk nodes they are also included (see example). The input is a changing number of file paths as described above. If I have 1 file I want 1 download node if i have 20 I want 20. I never get errors, I just see even with the chunk node always just 1 download button for one file - even if there are more files.

HTH,
Lars

Thanks for the info @laval . I have a few questions:

  1. Is this running off a Knime server and via the Knime front-end (webportal)? Interactions such as this behave differently when run in front-end vs back-end
  2. Is there any particular reason to use Parallel Chunk Start?
  3. What is the overall idea behind this component? I mean why is this in a component? This is more to understand if this is the best way to do this or not.

Hi @bruno29a ,
thank you, here are my answers

  1. The workflow will be hosted on a KNIME Server as soon as it is fully functional to serve as a web service.

  2. I tried to describe that already in the start post. I was trying to find a new automatic solution instead of the above described solutions I do regularly. The parallel chunk is the only option I know to automatically create branches - but it didn’t work out the way I was hoping.

  3. A component must be used if the interaction nodes of KNIME should be visible as a webpage on the KNIME Server (KNIME Components Guide).
    In my Case the Download node will appear as a download button for one file. The aim is still to get automatically as many download buttons as needed to download the changing number of different files individually. Coding something with JS is no option.

I still want to find out if there are better solutions in KNIME already available.

Best,
Lars

Thanks for the additional info @laval . So, if I understood properly, you want to see all the download buttons at once on the same page, rather than going through multiple pages with single download button, correct? And the use of the Parallel Chunk Start here is an attempt to achieve this, correct?

And the use of the Component is more because of the interaction than creating a re-useable Download File component, correct?

This is going to be a tricky one…

@bruno29a Exactly, if the workflow is creating one file I want on one single page one button for that file and if I have 10, I want to see ten individual buttons, one for each file, on the same page, but not on multiple pages. And yes, the Parallel Chunk nodes were an idea to achieve that in an automatic way instead of doing it the manual old fashioned ways.

And ja, the component is to give the user a nice button to klick on. It stands here as a placeholder which could be replaced with other interesting nodes in other use cases. The question is about the automatic creation of branches.

Ja, I am expecting this is not easy unless there are new functionalities added in the recent years which I might have missed - thats why I am asking in the forum now.

Many thanks,
Lars

Hi @laval , ok, now that you have confirmed what it is you want to achieve, I have come up with an alternative solution as I don’t think it is possible to do this via loops, even with parallel chunk loop.

The way I’m thinking about this is, one way to have all download buttons displayed is to basically add them for each record that you have.

I added the html code that would point to the file to the table, so each record of the table would have it’s own download link (in this case, it would be a link rather than a button, though you can still add a button and implement some events such as onClick via js, but you want to avoid js as per my understanding), and then use a table view to see the html code being executed.

For example, this is what I have:
image

Basically in your case, the String Manipulation and Table View would be what would replace your component - the List Files and Path to String from my workflow is basically generating some file path, which you should already have in your workflow, whatever is before your component.

My String Manipulation is just adding the typical html <a href> tag, like this:
join("<a href=\"", $Location$, "\">", "Download", "</a>")

I separated the word “Download” as you can customize the wording as you like.

And this is how the Table View looks like:

As you can see, there are as many Download links as there are files.

Of course, you can customize how the view looks like, or what to show in the view.

Here’s my workflow:
File download links.knwf (11.2 KB)

4 Likes

@bruno29a Thanks a lot for all the work u invested. I am not sure if it will work on the server in the webportal this way, I used the REST Api in the past to create download links for a list to achive what you are suggesting. That works well.

But my question is not really how to create download links - it is how to automise branches and nodes.

This here is just an example and another node than the download button could be needed in the future, since I ran into this issue from time to time during the last years.

Best,
Lars

Hi @laval,

@bruno29a has provided a great answer. There is no way to dynamically add Widgets on the WebPortal right now. There is a ‘refresh’ button that will take any new changes the user inputs and redisplay the current page on Servers 4.13.0+.

What's New in KNIME Analytics Platform 4.4 and KNIME Server 4.13 | KNIME

The only other way would be to re-display the page with a loop for each iteration.

Regards,
Wali Khan

4 Likes

Hi @wkhan thanks a lot for clarifying that for my use case no solution is available at the moment from KNIME side. Maybe in the future - may you note that as a feature request? :slight_smile:

I am aware of the refresh button and I like the idea of it for other use cases (have already opened a few requests to extend that feature).

Best,
Lars

Hi @laval

I have opened WEBP-833 for the feature request. Glad you like the refresh button!

Regards,
Wali Khan

3 Likes