akamai / NetStorageKit-Node

Akamai NetStorage API for Node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Down/Upload Progress

aarlaud opened this issue · comments

It's more a question than an issue. Do you know how I would go about getting a idea of how far along a download/upload is?
I'm thinking comparing remote and local file sizes somehow, but any suggestions of how to go about it?

thanks!
Antoine

Hey, @aarlaud. Only speaking as a contributor here, so the owner may have some other things to say.

This is tricker than one might think, and is a consistent problem with http/s libraries as well as request. When directly invoking those libraries, there are ways to accomplish this (sort of messily). However, the SDK obfuscates away the http/s libraries for actually making the request, and opts for use of fs-based file inputs and callbacks rather than streams/emitters (in terms of the actual upload method).

By their nature, callbacks are only called on completion or failure (since they are only called once). To accomplish allowing the SDK consumer to calculate progress, we'd likely have to move to an emitter pattern so that the req/res variables and/or events are exposed. That would definitely be a non-trivial change, and certainly a breaking one (in terms of symver).

Thanks for the response. I think I may have an idea that I need to experiment with, I'll provide update if I can make something useful ;). Please close the issue in the meantime.

commented

Dear @aarlaud,
I will consider it for the next update. Thanks for your suggestion !