How to use basic-ftp - 10 common examples

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 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 = {
      host: connection.host,
      port: (connection.port) ? connection.port : 21,
      user: connection.user,
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);
github qusly / qusly-core / src / utils / file.ts View on Github external
export const getFileType = (type: FileType): IFileType => {
  switch (type) {
    case FileType.Directory: {
      return 'folder';
    }
    case FileType.File: {
      return 'file';
    }
    case FileType.SymbolicLink: {
      return 'symbolic-link';
    }
  }

  return 'unknown';
}
github qusly / qusly-core / src / utils / file.ts View on Github external
export const getFileType = (type: FileType): IFileType => {
  switch (type) {
    case FileType.Directory: {
      return 'folder';
    }
    case FileType.File: {
      return 'file';
    }
    case FileType.SymbolicLink: {
      return 'symbolic-link';
    }
  }

  return 'unknown';
}
github qusly / qusly-core / src / utils / file.ts View on Github external
export const getFileType = (type: FileType): IFileType => {
  switch (type) {
    case FileType.Directory: {
      return 'folder';
    }
    case FileType.File: {
      return 'file';
    }
    case FileType.SymbolicLink: {
      return 'symbolic-link';
    }
  }

  return 'unknown';
}
github qusly / qusly-core / src / models / client.ts View on Github external
        return list.map(file => formatFile(parseList(file.longname)[0]));
      } else {

basic-ftp

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

MIT
Latest version published 10 months ago

Package Health Score

80 / 100
Full package analysis