0.0.0 • Published 9 years ago
file-transfer v0.0.0
file-transfer
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) -> PromiseParameters
| Parameter | Type(s) | Required | Default | Description |
|---|---|---|---|---|
protocol | string | No | Protocol name (sftp, ftp or webdav) | |
options | object | Yes | Connection 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) -> disposerdisposer() use the same parameters as connect().
Client API
License
See License
0.0.0
9 years ago