dcc.Upload callback at the start?


I am using the dcc.Upload component and would like to have a notification while the data is being loaded, that gets updated once the upload successful.
We can easily have a callback at the end of the data upload, but I could not find a way on how to trigger a callback when the data upload is starting (either by dropping files on the selected zone or clicking on the file browser)…

Is this possible? Am I missing something obvious?


Hello @hcoohb,

For this, you can use a background callback, which gives the option of giving a progress indicator.

As a byproduct, you can also change the state of a loading spinner as well if you wanted.

this below can also do this.

@jinnyzor and @stu , Thanks for the quick reply.

But my problem is more that I do not see a trigger for the Upload start.
From the doc https://dash.plotly.com/dash-core-components/upload, defining the callback:

@app.callback(Output('output-image-upload', 'children'),
              Input('upload-image', 'contents'))
def update_output(list_of_contents, ):

means the Input is only triggered once the upload is already finished.
So how would I start a background callback or BlockingCallbackTransform at the start of the data upload?



Can you provide more code? How big are the files that you are trying to transfer? That seems pretty big to want to see that something is currently being transfer…

Have you tried using loading_state to trigger?