ab-ftp
v1.2.1
Published
FTP client wrapper
Downloads
27
Readme
ab-ftp
FTP service wrapper using ES6 Promises.
Based on node-ftp package
Installation
npm install ab-ftp
Usage
Import the module const ftp = require('ab-ftp')
and get a reference to work.
Create a client instance with your settings let client = new ftp(user, password, host)
Then you can operate with a basic set of methods
UPLOAD
let client = new ftp(user, password, host)
client.connect()
.then(() => {
const fs = require('fs')
fs.readFile('./test/test.js', (err, data) => {
client.postFile(data, 'test.js')
.then(() => assert(true))
.catch(err => console.error(err))
})
})
.catch(err => console.error(err))
DOWNLOAD
let client = new ftp(user, password, host)
client.connect()
.then(() => {
client.getFile('test.js')
.then(() => assert(true))
.catch(err => console.error(err))
})
.catch(err => console.error(err))
LIST DIRECTORY
let client = new ftp(user, password, host)
client.connect()
.then(() => {
client.listDirectory('test')
.then(result => console.log(`items: ${result.length}`))
.catch(err => console.error(err))
})
.catch(err => console.error(err))
REMOVE
let client = new ftp(user, password, host)
client.connect()
.then(() => {
client.deleteFile('test.js')
.then(() => assert(true))
.catch(err => console.error(err))
})
.catch(err => console.error(err))
Road map
Operational methods can accept a single connection More operations to wrap
Licence
The MIT License (MIT)
Copyright (c) 2016 [Àgora Binaria] (http://agorabinaria.com)