Class: SFTPClient

SFTPClient(config)

new SFTPClient(config)

Constructor for creating SFTPClient
Parameters:
Name Type Description
config *
Source:

Methods

createReadStream()

get a readable stream to remote file
Source:

createWriteStream()

get a writable stream to remote file
Source:

get(remotepath, localpath, sessionopt)

get remote file and save it locally
Parameters:
Name Type Attributes Description
remotepath string path to remote file
localpath string destination path on local filesystem
session ssh2.Client <optional>
existing ssh2 connection, optional
Source:

getBuffer(path, sessionopt) → {Promise}

get remote file contents into a Buffer
Parameters:
Name Type Attributes Description
path string on filesystem to stat
session ssh2.Client <optional>
existing ssh2 connection, optional
Source:
Returns:
Promise with Buffer on resolve
Type
Promise

getStream()

stream file contents from remote file
Source:

ls(path, sessionopt) → {Promise}

unix ls -l style return
Parameters:
Name Type Attributes Description
path string on filesystem to stat
session ssh2.Client <optional>
existing ssh2 connection, optional
Source:
Returns:
Promise with object describing path
Type
Promise

mkdir(path, sessionopt)

makes a directory
Parameters:
Name Type Attributes Description
path string remote directory to be created
session ssh2.Client <optional>
existing ssh2 connection, optional
Source:

mv(source, destination, sessionopt)

move remote file from one spot to another
Parameters:
Name Type Attributes Description
source string remote filesystem source path
destination string remote filesystem desitnation path
session ssh2.Client <optional>
existing ssh2 connection, optional
Source:

put(localpath, remotepath, sessionopt)

put local file in remote path
Parameters:
Name Type Attributes Description
localpath string path to local file
remotepath string destination path on remote filesystem
session ssh2.Client <optional>
existing ssh2 connection, optional
Source:

putBuffer(buffer, path, sessionopt) → {Promise}

put buffer to remote file
Parameters:
Name Type Attributes Description
buffer Buffer Buffer containing file contents
path string on filesystem to stat
session ssh2.Client <optional>
existing ssh2 connection, optional
Source:
Returns:
Promise with boolean true if tranfer was successful
Type
Promise

putStream()

stream file contents from local file
Source:

rm(path, sessionopt)

remove remote file
Parameters:
Name Type Attributes Description
path string remote file to remove
session ssh2.Client <optional>
existing ssh2 connection, optional
Source:

rmdir(path, sessionopt)

removes and empty directory
Parameters:
Name Type Attributes Description
path string remote directroy to remove
session ssh2.Client <optional>
existing ssh2 connection, optional
Source:

session() → {Promise}

creates a new ssh2 session, short cut for sshClient = require('ssh2')sshClient session = new SFTPClient(config)
Source:
Returns:
returns a Promse with an ssh2 connection object if resovled
Type
Promise

sftpCmd(cmdCB, sessionopt)

Creates connection and promise wrapper for sftp commands
Parameters:
Name Type Attributes Description
cmdCB callback callback for sftp, takes connection, reject and resolve cmb_cb(con, reject,resolve)
session ssh2.Client <optional>
existing ssh2 connection, optional
Source:

stat(path, sessionopt) → {Promise}

stat a file or directory
Parameters:
Name Type Attributes Description
path string on filesystem to stat
session ssh2.Client <optional>
existing ssh2 connection, optional
Source:
Returns:
Promise with object describing path
Type
Promise