Make sure to check the demo app(s) for sample usage
Make sure to check the existing issues in this repository
If the demo apps cannot help and there is no issue for your problem, tell us about it
Please, ensure your title is less than 63 characters long and starts with a capital
letter.
Which platform(s) does your issue occur on?
Android
Emulator
Please, provide the following version numbers that your issue occurs with:
CLI: (6.5.9)
I want to wait until all the files are downloaded before I show the start button but the button becomes active even before files are fully downloaded
let getFiles = async (paths) => {
let downloader = (args) => {
return new Promise((resolve, reject) => {
downloadManager = new Downloader();
let promises = [];
const documents = fs.knownFolders.documents();
args.forEach((data, index) => {
let file = exports.getFileName(data.pageUrl.downloadURL);
let url = data.pageUrl.downloadURL;
//check if this file was downloaded already
const path = fs.path.join(documents.path,file);
const exists = fs.File.exists(path);
if (exists === false) {
let promise = downloadManager.createDownload({
path: fs.knownFolders.documents().path,
fileName: file,
url:url
});
promises.push(promise);
}
});
resolve(promises);
})
}
let finishDownload = async (ids) => {
page.bindingContext.downloadedFiles._array.splice(0);
ids.forEach((data,index) => {
downloadManager
.start(data, (progressData) => {
// console.log(data+" id: download value,",progressData.value);
// console.log(data+" id: download speed,",progressData.speed);
})
.then(completed => {
console.log(`downloaded File path: ${completed.path}`);
}).catch(error => {
console.log("downloadManager error: ",error.message);
});
})
//this is always returned, even before files are downloaded.
return "done";
}
let y = await downloader(paths);
let x = await finishDownload(y);
if (x === "done") {
console.log("are we now finished!!!!!!!!");
hideLoading();
console.dir("all files are now downloaded and about to be saved!!!");
let file = exports.getFileName(page.navigationContext.pages[0].pageUrl.downloadURL);
//check if this file was downloaded already
let documents = fs.knownFolders.documents();
const path = fs.path.join(documents.path,file);
const exists = fs.File.exists(path);
if (exists) {
modalContentButton.class = "modal-content-button-active";
}
}
}
Can anyone assist with this? I think the issue is the finishDownload because it always returns before the files are downloaded and I cannot use an await before the downloadManager. If there is better way to do this please let me know.
Make sure to check the demo app(s) for sample usage
Make sure to check the existing issues in this repository
If the demo apps cannot help and there is no issue for your problem, tell us about it
Please, ensure your title is less than 63 characters long and starts with a capital letter.
Which platform(s) does your issue occur on?
Android Emulator
Please, provide the following version numbers that your issue occurs with:
I want to wait until all the files are downloaded before I show the start button but the button becomes active even before files are fully downloaded
let getFiles = async (paths) => {
}
Can anyone assist with this? I think the issue is the finishDownload because it always returns before the files are downloaded and I cannot use an await before the downloadManager. If there is better way to do this please let me know.