webdav-client icon indicating copy to clipboard operation
webdav-client copied to clipboard

onUploadProgress is not triggering.

Open cihanbey211 opened this issue 3 years ago • 2 comments

Hi everyone; Firstly thank you for this module. I need onUploadProgress trigger for big files, but not triggering. I need help yours about issue.

function uploadFile(client) { console.log('Start'); const file = fs.createReadStream("./video.mp4"); client.putFileContents("/video.mp4", file, { overwrite: false, onUploadProgress: progress => { console.log(progress); } }); }

cihanbey211 avatar Sep 07 '22 13:09 cihanbey211

Hi @cihanbey211 - just confirming, are you using this in the browser or node?

perry-mitchell avatar Sep 08 '22 17:09 perry-mitchell

Hi @cihanbey211 - just confirming, are you using this in the browser or node?

Hi sir, i couldn't get views on either side, is there a way you suggest?

cihanbey211 avatar Sep 09 '22 10:09 cihanbey211

@perry-mitchell, I also have this issue. I'm using it in the browser, but it only triggers once when the upload is done.

mtdvlpr avatar Nov 27 '22 09:11 mtdvlpr

I'm not sure what could be happening here, though to be honest I've not really used those functions in my own projects. From what I've seen they are incredibly unstable and work for some while never for others. That and such methods are not available on the new Fetch standard.

It's sad to say but these methods (upload/download progress) will disappear on v5 of this library, when I switch away from Axios (for Fetch). Progress will be possible to calculate by viewing the stream position when streaming files to or from the remote source, but not via normal options. I don't want to implement these myself (as they'd be problematic, just bloat for most people and only available reliably on the Node side).

I'll leave this issue open if someone's interested in fixing this for V4 (not sure how that'd be possible, as we simply pass these properties on to Axios, so any bug is most likely there), but I'll close it when V5 is stable.

perry-mitchell avatar Nov 27 '22 19:11 perry-mitchell

Okay, thanks for the explanation!

mtdvlpr avatar Nov 27 '22 21:11 mtdvlpr

Confirmed with the latest set of changes - upload/download progress will be dropped. Using streams + middleware to measure progress is the best way, especially because streams are better than buffering an entire file beforehand (usually required to be able to know upload size, and therefore progress (total/percentage)).

I'll try to add an example for this at some point.

perry-mitchell avatar Nov 30 '22 19:11 perry-mitchell