Skip to content

getPercentCompleted returns only 0 and 100 #87

Description

@sushibear

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions