-
Notifications
You must be signed in to change notification settings - Fork 30
Migration Guide
Niko Pasanen edited this page Apr 20, 2022
·
8 revisions
In dash-uploader 0.7.0, the multifile upload functionality has been fixed. The underlying technology was changed to flow.js (from resumable.js).
- There is a backwards incompatible change in the
@du.callback
syntax. Thefilenames
argument (list of str) was changed tostatus
(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. Fromflow.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.
- Changed the CSS class of the component to be
dash-uploader-completed
, instead ofdash-uploader-complete
, when upload is completed.