Skip to content

Migration Guide

Niko Pasanen edited this page Apr 20, 2022 · 8 revisions

0.6.0 → 0.7.0

In dash-uploader 0.7.0, the multifile upload functionality has been fixed. The underlying technology was changed to flow.js (from resumable.js).

Callbacks

  • There is a backwards incompatible change in the @du.callback syntax. The filenames argument (list of str) was changed to status (du.UploadStatus).
  • The support for @app.callback was removed (see below)
  • Previously (0.3.0 to 0.6.0) the callback syntax was
import dash_html_components as html
import dash_uploader as du

@du.callback(
    output=Output('callback-output', 'children'),
    id='dash-uploader',
)
def callback_on_completion(filenames): # <------- OLD: list of filenames
    return html.Ul([html.Li(filenames)])

And now it is

import dash_html_components as html
import dash_uploader as du

@du.callback(
    output=Output("callback-output", "children"),
    id="dash-uploader",
)
def callback_on_completion(status): # <------- NEW: du.UploadStatus
    return html.Ul([html.Li(str(x)) for x in status.uploaded_files])

The du.UploadStatus object has following attributes:

  • status.latest_file (pathlib.Path): The full file path to the file that has been latest uploaded
  • status.uploaded_files (list of pathlib.Path): The list of full file paths to all of the uploaded files. (uploaded in this session)
  • status.is_completed (bool): True if all the files have been uploaded
  • status.n_uploaded (int): The number of files already uploaded in this session
  • status.n_total (int): The number of files to be uploaded.
  • status.uploaded_size_mb (float): Size of files uploaded in Megabytes
  • status.total_size_mb (float): Total size of files to be uploaded in Megabytes
  • status.upload_id (str or None): The upload id used in the upload process, if any.
  • status.progress (float): From 0 to 1, indicating the current upload progress of all files. From flow.progress().

Note: Using the @app.callback syntax, like

@app.callback(
    Output('callback-output', 'children'),
    [Input('dash-uploader', 'isCompleted')],
    [State('dash-uploader', 'fileNames'),
     State('dash-uploader', 'upload_id')],
)
def some_callback():
    # do stuff

is not supported anymore in 0.7.0, as the attributes of the underlying JS component are considered as implementation details. Although, it is possible if you really need to do so, for example when writing tests for dash-uploader, when developing a new feature. For details, search for app.callback in the source code.

Other

  • Changed the CSS class of the component to be dash-uploader-completed, instead of dash-uploader-complete, when upload is completed.
Clone this wiki locally