nextcloud-node-client
nextcloud-node-client copied to clipboard
getPercentCompleted returns only 0 and 100
Hey there...
I was just trying to async upload a larger video file following your example here: https://github.com/hobigo/nextcloud-node-client/blob/master/docs/upload.md
But the console log only returns 0 or 100 when using the getPercentCompleted() command?
My Code:
let files = [{ sourceFileName: sourceFile, targetFileName: targetFile }];
let uc = new UploadFilesCommand(newClient, { files });
uc.execute();
while (uc.isFinished() !== true) {
await (async () => { return new Promise(resolve => setTimeout(resolve, 1000)) })();
console.log(uc.getPercentCompleted() + "%");
}
const uploadResult = uc.getResultMetaData();
if (uc.getStatus() === CommandStatus.success) {
console.log(uploadResult.messages);
console.log(uc.getBytesUploaded());
} else {
console.log(uploadResult.errors);
}
Here is my output:
0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 100% [ '/video.mp4' ] 80275042
Or is this correct and it only returns IF the command UploadFilesCommand was completed? Sounds weird to me and is not really what I would expect. I would like to show the percentage of the file in progress.