Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Client = require('ftp');
  2. export class FTP {
  3.   username: string;
  4.   password: string;
  5.   host: string;
  6.   port: number;
  7.   c : any;
  8.  
  9.   constructor(username,password,host,port){
  10.     this.username = username;
  11.     this.password = password;
  12.     this.host = host;
  13.     this.port = port;
  14.     var c = new Client();
  15.   }
  16.  
  17.   connect(){
  18.     this.c.on('ready', function() {
  19.     this.c.list(function(err, list) {
  20.       if (err) throw err;
  21.         console.dir(list);
  22.       this.c.end();
  23.     });
  24.   });
  25.   // connect to localhost:21 as anonymous
  26.   var connectProps = {
  27.     host: this.host,
  28.     port: this.port,
  29.     user: this.username,
  30.     password: this.password
  31.   }
  32.   this.c.connect(connectProps);
  33.   }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement