1.0.0 • Published 5 months ago

ftp-upload-helper v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

ftp-upload-helper

A Node.js library for uploading files and directories to FTP servers.

Installation

npm install ftp-upload-helper

Usage

const FtpUploader = require('ftp-upload-helper');

// Create an instance with FTP configuration
const uploader = new FtpUploader({
  host: 'ftp.example.com',
  user: 'username',
  password: 'password',
  port: 21 // default FTP port
});

// Upload a single file
uploader.uploadFile('path/to/local/file.jpg', '/remote/directory/')
  .then(() => console.log('File uploaded successfully'))
  .catch(err => console.error('Upload failed:', err));

// Upload an entire directory
uploader.uploadDirectory('path/to/local/directory', '/remote/directory/')
  .then(() => console.log('Directory uploaded successfully'))
  .catch(err => console.error('Upload failed:', err));

Features

  • Upload single files to FTP server
  • Upload entire directories recursively
  • Progress tracking
  • Promise-based API
  • Error handling

API

Constructor

new FtpUploader(config)

Config options:

  • host: FTP server hostname
  • user: FTP username
  • password: FTP password
  • port: FTP port (default: 21)
  • secure: Use FTPS (default: false)

Methods

uploadFile(localPath, remotePath)

Uploads a single file to the FTP server.

  • localPath: Path to the local file
  • remotePath: Target directory on the FTP server
  • Returns: Promise

uploadDirectory(localPath, remotePath)

Uploads an entire directory recursively to the FTP server.

  • localPath: Path to the local directory
  • remotePath: Target directory on the FTP server
  • Returns: Promise

License

This project is licensed under the MIT License - see the LICENSE file for details.

1.0.0

5 months ago