This repository was archived by the owner on Feb 5, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,42 @@ The high level client is an instance of `Client`, but it contains the high level
191
191
192
192
download a server file to local.
193
193
194
+ ### Example with progress bar (download from server)
195
+
196
+ You can easily combine this module with the ` progress ` npm package, to get live progress data in your commandline interface. Example below:
197
+
198
+ ``` javascript
199
+ var scp2 = require (' scp2' );
200
+ var ProgressBar = require (' progress' );
201
+
202
+ var client = new scp2.Client ();
203
+ var bar;
204
+
205
+ client .on (' transfer' , function (buf , downloaded , total ) {
206
+ if (! bar) {
207
+ bar = new ProgressBar (' downloading [:bar] :rate/bps :percent :etas' , {
208
+ complete: ' =' ,
209
+ incomplete: ' ' ,
210
+ width: 20 ,
211
+ total: total
212
+ });
213
+ }
214
+ bar .tick (buf .length );
215
+ });
216
+
217
+ scp2 .scp ({
218
+ host: ... ,
219
+ username: ... ,
220
+ password: ... ,
221
+ path: ' /path/to/src/file'
222
+ }, ' /path/to/dest/file' , client, function (err ) {
223
+ if (err) {
224
+ console .log (err);
225
+ }
226
+
227
+ // Do stuff with the downloaded file
228
+ });
229
+ ```
194
230
195
231
## Events
196
232
You can’t perform that action at this time.
0 commit comments