npm

Need private packages and team management tools?Check out npm Orgs. »

ab-ftp

1.2.1 • Public • Published

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

Keywords

install

npm i ab-ftp

Downloadsweekly downloads

2

version

1.2.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability