Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ftp

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ftp

An FTP client module for node.js

  • 0.3.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is ftp?

The ftp npm package is a client for the File Transfer Protocol (FTP), which allows for the transfer of files between a client and a server on a computer network. It provides methods to read and write files, navigate the directory structure, and manage files and directories on the server.

What are ftp's main functionalities?

Connecting to an FTP server

This code sample demonstrates how to establish a connection to an FTP server using the ftp package. You need to provide the host, user, and password to connect.

const FTP = require('ftp');
const client = new FTP();
client.connect({ host: 'ftp.example.com', user: 'username', password: 'password' });

Listing files in a directory

This code sample shows how to list all files in a specific directory on the FTP server.

client.list('/path/to/directory', (err, list) => {
  if (err) throw err;
  console.dir(list);
});

Downloading a file

This code sample illustrates how to download a file from the FTP server. It saves the file to a local path.

client.get('remote/file/path.txt', (err, stream) => {
  if (err) throw err;
  stream.once('close', () => { client.end(); });
  stream.pipe(fs.createWriteStream('local/file/path.txt'));
});

Uploading a file

This code sample demonstrates how to upload a file to the FTP server from a local path.

client.put('local/file/path.txt', 'remote/file/path.txt', (err) => {
  if (err) throw err;
  client.end();
});

Deleting a file

This code sample shows how to delete a file from the FTP server.

client.delete('remote/file/path.txt', (err) => {
  if (err) throw err;
  console.log('File deleted successfully');
});

Other packages similar to ftp

Keywords

FAQs

Package last updated on 05 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc