How to use the ftp.prototype function in ftp

To help you get started, we’ve selected a few 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 liximomo / vscode-sftp / src / core / remote-client / ftpClient.ts View on Github external
import * as Client from 'ftp';
import RemoteClient, { ConnectOption } from './remoteClient';

// tslint:disable
Client.prototype._send = function(cmd: string, cb: (err: Error) => void, promote: boolean) {
  clearTimeout(this._keepalive);
  if (cmd !== undefined) {
    if (promote) this._queue.unshift({ cmd: cmd, cb: cb });
    else this._queue.push({ cmd: cmd, cb: cb });

    if (cmd === 'ABOR') {
      if (this._pasvSocket) this._pasvSocket.aborting = true;
      this._debug && this._debug('[connection] > ' + cmd);
      this._socket.write(cmd + '\r\n');
      return;
    }
  }
  var queueLen = this._queue.length;
  if (!this._curReq && queueLen && this._socket && this._socket.readable) {
    this._curReq = this._queue.shift();
    if (this._curReq.cmd !== 'ABOR') {
github liximomo / vscode-sftp / src / core / remote-client / ftpClient.ts View on Github external
this._socket.write(cmd + '\r\n');
      return;
    }
  }
  var queueLen = this._queue.length;
  if (!this._curReq && queueLen && this._socket && this._socket.readable) {
    this._curReq = this._queue.shift();
    if (this._curReq.cmd !== 'ABOR') {
      this._debug && this._debug('[connection] > ' + this._curReq.cmd);
      this._socket.write(this._curReq.cmd + '\r\n');
    }
  } else if (!this._curReq && !queueLen && this._ending) this._reset();
};
// tslint:enable

Client.prototype.setLastMod = function(path: string, date: Date, cb) {
  const dateStr =
    date.getUTCFullYear() +
    ('00' + (date.getUTCMonth() + 1)).slice(-2) +
    ('00' + date.getUTCDate()).slice(-2) +
    ('00' + date.getUTCHours()).slice(-2) +
    ('00' + date.getUTCMinutes()).slice(-2) +
    ('00' + date.getUTCSeconds()).slice(-2);

  this._send('MFMT ' + dateStr + ' ' + path, cb);
};

export default class FTPClient extends RemoteClient {
  private connected: boolean = false;

  _initClient() {
    return new Client();

ftp

An FTP client module for node.js

MIT
Latest version published 10 years ago

Package Health Score

68 / 100
Full package analysis