HomeDocs
Skip to main content

DownloadTask.onProgressUpdate(function listener)

Introduction​

Listen to download progress change events.

Parameters​

function listener

The listener function for download progress change events.

Parameters​

Object res​

AttributeTypeDescription
progressnumberDownload progress in percentage.
totalBytesWrittennumberThe length of data that has been downloaded, in Bytes.
totalBytesExpectedToWritenumberThe total length of data expected to be downloaded, in Bytes.

Sample Code​

// pages/index/index.js

Page({
downloadFile() {
const downloadFileTask = dlt.downloadFile({
url: "xxx",
success(res) {
console.log(res);
},
fail(res) {
console.error(res);
},
});

downloadFileTask.onProgressUpdate((res) => {
console.log("Download Progress:", res.progress);
console.log("Data length already downloaded:", res.totalBytesWritten);
console.log("Total expected data length to download:", res.totalBytesExpectedToWrite);
});
},
});
Privacy agreementDeveloper agreementcontact us: developer_private.mi@dlightek.com © 2024 MiniApp. All Rights Reserved.