0.0.0 • Published 8 years ago

file-transfer v0.0.0

Weekly downloads
67
License
MIT
Repository
github
Last release
8 years ago

file-transfer

npm Build Status Coverage Status dependencies Status devDependencies Status

Multiprotocol file transfer

Supported protocols

  • SFTP
  • FTP
  • WebDAV

Usage

var transfer = require('file-transfer');

transfer.connect('sftp', {
  host:     'sftp.example.com',
  username: 'foo',
  password: 'bar'
}).then(function (client) {
  // Work with client

  client.disconnect();
});

Automatic disconnection

To ensure the client connection is closed after the work is done, you can use the disposer() function. It take the same paramerters as connect() and returns a Bluebird's disposer that will close the connection when the returning Promise is resolved.

var transfer = require('file-transfer');

var Promise = require('bluebird');

var disposer = transfer.disposer({
  protocol: 'sftp',
  host:     'sftp.example.com',
  username: 'foo',
  password: 'bar'
});

Promise.using(disposer, function (client) {
  // Work with client
}).then(function () {
  // The connection is closed
});

Documentation

Client initialization

This module expose two functions to initialize a connection.

connect

Open the connection to the remote server.

Usage
transfer.connect([protocol], options) -> Promise
Parameters
ParameterType(s)RequiredDefaultDescription
protocolstringNoProtocol name (sftp, ftp or webdav)
optionsobjectYesConnection parameters (see Client constructor options)

The protocol can be passed as the first parameter, or as an options property.

disposer

Open the connection to the remote server and return a disposer to automatically close the connection (see Bluebird's disposer documentation).

Usage
transfer.disposer([protocol], options) -> disposer

disposer() use the same parameters as connect().


Client API

License

See License