npm install distribute-files
var Distributor = require("distribute-files").Distributor;
new Distributor({
debug: Boolean, // Show debug messages
root: String, // The root for all local files, leave empty if none should be used, you will have to supply an absolute path later,
servers: [
{
type: "ftp",
connection: { // see https://www.npmjs.com/package/ftp for all available options
host: "example.com",
port: 21,
user: "foo",
password: "bar"
},
root: null // if you supply a root, all target paths will be prefixed, ths is to enable different roots on different servers
}, {
type: "sftp",
connection: { // see https://www.npmjs.com/package/ssh2-sftp-client for all available options
host: "example.com",
port: 22,
user: "foo", // alias for the original username param, you can use both this is just to keep the api clean(ish)
password: "bar"
},
root: null // if you supply a root, all target paths will be prefixed, ths is to enable different roots on different servers
},
function(file) { // completely custom transfer function, is expected to return a Promise, if you do something cool, add it to the transfer methods and pull request?
}
]
})
new Distributor({
root: process.cwd(),
servers: [
{
type: "sftp",
connection: {
port: 2222,
host: "demo.wftpserver.com",
user: "demo-user",
password: "demo-user"
},
root: "/"
},
{
type: "ftp",
connection: {
host: "speedtest.tele2.net"
},
root: "/upload"
}
]
}).distributeFile("/file1.txt", "file1.text").then(success, error)
new Distributor({
root: process.cwd(),
servers: [
{
type: "sftp",
connection: {
port: 2222,
host: "demo.wftpserver.com",
user: "demo-user",
password: "demo-user"
},
root: "/"
},
{
type: "ftp",
connection: {
host: "speedtest.tele2.net"
},
root: "/upload"
}
]
}).distributeFiles([
"/file1.txt",
"/file2.txt"
], [
"/anotherpath/file1.text"
"/anotherpath/file2.text"
]).then(success, error)
Distribute/Upload any number of files to any number of servers.
Transfers as tmp files to ensure the data on the server is always valid. Removes tmp files if anything fails during the process.
FTP
SFTP
Custom Function
npm install mocha -g
npm install
npm test