How to use the basic-ftp.Client function in basic-ftp

To help you get started, we’ve selected a few basic-ftp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github h3imdall / ftp-remote-edit / lib / connectors / ftp.js View on Github external
connect(connection) {
    const self = this;
    self.emit('debug', 'ftp:connect');

    self.client = new ftpClient.Client();

    // force PASV mode
    self.client.prepareTransfer = ftpClient.enterPassiveModeIPv4;

    // logging
    self.client.ftp.verbose = true;
    self.client.ftp.log = (message) => {
      if (message.startsWith('<') || message.startsWith('>')) {
        self.emit('log', message.replace(/\'+/g, "").replace(/\\r|\\n/g, " "));
      } else {
        self.emit('debug', 'ftp:debug: ' + message);
      }
    };

    // options
    let options = {
github qusly / qusly-core / src / models / client.ts View on Github external
public async connect(config: IConfig): Promise {
    if (this.connected) {
      await this.disconnect();
    }

    this.config = config;
    this.connected = false;

    if (this.isSftp) {
      this._sftpClient = new SftpClient();
      await this._sftpClient.connect(config);
    } else {
      this._ftpClient = new FtpClient();

      const ftps = config.protocol === 'ftps';

      await this._ftpClient.access({
        secure: ftps,
        secureOptions: ftps ? null : {
          rejectUnauthorized: false,
        },
        ...config
      });
    }

    this.connected = true;
    this.emit('connect');
  }
github reruin / sharelist / plugins / drive.ftp.js View on Github external
let { username, password, hostname, port, pathname } = new URL(url);
    /*
    let client = clientMap[key]

    if (client && client.closed == false) {
      if (pathname) {
        if (cd) {
          pathname = pathname.replace(/\/[^\/]+?$/, '')
        }
        console.log('cd1')
        await client.cd(pathname);
      }
      return client
    } 
    */
    let client = new ftp.Client();
    let flag = false
    client.ftp.verbose = true
    try {
      let p = await client.access({
        host: hostname,
        user: decodeURIComponent(username),
        password: decodeURIComponent(password),
        port: port || 21,
        secure: false
      })
      if (pathname) {
        if (cd) {
          pathname = pathname.replace(/\/[^\/]+?$/, '')
        }
        await client.cd(pathname);
      }
github microsoft / azure-pipelines-tasks / Tasks / FtpUploadV2 / ftpuploadtask.ts View on Github external
async function getFtpClient(options: FtpOptions): Promise {
    const ftpClient = new ftp.Client();
    ftpClient.ftp.log = tl.debug;
    const accessOptions = getAccessOption(options);
    const response = await ftpClient.access(accessOptions);
    tl.debug("ftp client greeting");
    console.log(tl.loc("FTPConnected", response.message));

    ftpClient.trackProgress(info => {
        console.log(
            `File: ${info.name} Type: ${info.type} Transferred: ${info.bytes}`
        );
    });

    return ftpClient;
}
github SeydX / homebridge-camera-ui / src / accessories / camera.js View on Github external
async handleFTP(){
  
    const client = new ftp.Client();
    
    client.ftp.verbose = false;
    
    let refresh = 10;
    
    try {
      
      await client.access({
        host: this.ftpConfig.host,
        user: this.ftpConfig.username,
        password: this.ftpConfig.password,
        secure: this.ftpConfig.secure
      });
        
      await client.cd(this.ftpConfig.absolutePath);

basic-ftp

FTP client for Node.js, supports FTPS over TLS, IPv6, Async/Await, and Typescript.

MIT
Latest version published 3 months ago

Package Health Score

82 / 100
Full package analysis