spmjs / node-scp2

[MAINTAINER WANTED] A pure javascript scp program based on ssh2.
384 stars 96 forks source link

Bytes transfered event in download method #43

Open charlietilt opened 8 years ago

charlietilt commented 8 years ago

Not sure if there is anyway to do this currently and if so let me know. I am looking for a way to setup a listener on the client to capture, on an interval, the progress of the file being downloaded.

Example:

client = new Scp2.Client config
    client.on 'transfer', (bytes) ->
      Logger.verbose "Bytes transfered (#{localFile}): #{bytes}"
    client.download remoteFile, localFile, (error) ->
      callback error, localFile

The only place that the 'transfer' event is currently emitted is in the Client.write method.

I made a Gist with some minor updates to Client.prototype.download to emit this. Any comments/thoughts? https://gist.github.com/charlietilt/8d6c64b50ebf688b47e1