Notify about progress when uploading / downloading files
What is this feature about?
Right now, when uploading or downloading a large file to or from file storage, you just have to wait. It would be great if there was an option to get notified about the progress being made. We already have figured out an API for this:
client.on(`progress::${id}`, ({ type, progress, elapsedTime, estimatedRemainingTime }) => {
// type: 'upload', 'download'
// progress: 0..100 (in %, not rounded)
// elapsedTime: 0..x (in milliseconds)
// estimatedRemainingTime: 0..x (in milliseconds)
});
Internally, once progress 100 has been reached, all event listeners for the appropriate ID should automatically be removed.
Additionally, you can provide an onProgress callback to the addFile and getFile calls.
What needs to be done to implement this feature?
- [x] Implement the new API in the wolkenkit-depot-client-js module
- [x] Add tests
- [ ] Update documentation
What else should we know?
This issue was brought up by @SteffenGottschalk, so we should notify him once this has been done.
Unfortunately, axios calls the onUploadProgess and onDownloadProgress events in a very unreliable way (which is probably caused by the underlying implementation of the browsers):
- In Node.js, the events are not supported at all.
- In Chrome (macOS and Windows) the events also never happen.
I didn't test Firefox, but if it doesn't work in Chrome, I think it's questionable whether it makes sense to implement this. I also tested this with a large file (of almost 2 gb in size), but again, no events happened.
Hence, I am going to close this issue, we won't implement this.