fohrloop / dash-uploader

The alternative upload component for python Dash applications.
MIT License
141 stars 29 forks source link

Multiple Upload components on different pages #127

Open jonte14 opened 11 months ago

jonte14 commented 11 months ago

Hi.

What I want to do principally is the following:

Page 1: main.py Here the app is initiated etc

Page 2: upload_agreement.py Here the user can upload a signed and filled agreement. It should be put in a specific folder "data/$UserName/agreements"

Page 3: upload_images.py Here the user can upload images (Multiple files) These should be put in specific folder "data/$UserName/images"

I am able to make this work with 2 pages by getting the app instance with dash.get_app(). In this way I use du.configure_upload(app, output_folder)

However, with 3 pages, I have not found a solution. The problem is that it seems that du.configure_upload(app, output_folder) must be present on the page where the du.Upload component is instantiated. However, when I add du.configure_upload(app, output_folder) to Page 3 I get the error:

AssertionError: View function mapping is overwriting an existing endpoint function: get

So it seems that the endpoint is defined globally, but still, the du.configure line must be present on each page where I use du.callback. But I cannot have this line present on all pages since that overwrites the endpoint of dash-uploader.

Is there a workaround?

nils-fl commented 3 months ago

It's been a while since the question has been asked, but I would also like to know how to use du.callback() on multiple pages. I have my du.configure_upload() in my app.py.

I am able to define the download folder by returning the du.Upload() in a normal callback with a specified upload_id that I get from Input("url", "search"). But I need to have a `du.callback()' to trigger other stuff when the upload is finished...