Black Lives Matter. Please consider donating to Black Girls Code today.

Reset/empty data in dcc.Upload

Hi all. I am new to Dash and so far have enjoyed the technology and learning process very much! I have an app that does a complicated calculation based on three uploads via dcc.Upload. The uploads and calculation all work as expected. The issue is that I do not understand the “canonical” method for basically resetting the data. That is, how do I reset the app to its initial empty state? Thanks alot for the opportunity to ask technical questions!

For reference, the upload layout is standard:

   dcc.Upload(
      id='upload-data1',
      children=html.Div(['Drag & Drop or ',html.A('Select ZMA File')]),
      style=style_upload,
      multiple=False
   ),
   dcc.Upload(
      id='upload-data2',
      children=html.Div(['Drag & Drop or ',html.A('Select ZMA File')]),
      style=style_upload,
      multiple=False
   ),
   dcc.Upload(
      id='upload-data3',
      children=html.Div(['Drag & Drop or ',html.A('Select ZMA File')]),
      style=style_upload,
      multiple=False
   ),

The callback looks like this:

@app.callback(Output('output-tabs','children'),
              [Input('upload-data1','contents'),
               Input('upload-data2','contents'),
               Input('upload-data3','contents')],
              [State('upload-data1','filename'),
               State('upload-data2','filename'),
               State('upload-data3','filename')])
def update_output(c1,c2,c3,f1,f2,f3):
   c = [] ; f = []
   if c1 is not None:
      c.append(c1) ; f.append(f1)
      if c2 is not None:
         c.append(c2) ; f.append(f2)
         if c3 is not None:
            c.append(c3) ; f.append(f3) 
   return do_calculation(c,f)