Skip to main content

FTP

FTP client module that provides an asynchronous interface for communicating with an FTP server.

Tagsshell
Network Connection needs

This integration needs network access to the server where the service is running.

See the Network access page for details about how to achieve that.

tip

If you are looking for an integration to work with SSH File Transfer Protocol (SFTP), you should use our SFTP integration.

Credential configuration

To configure this credential, you need the host, user and password to connect to the FTP server.

Optionally, you can set any of the extra config parameters you can see here.

Here is an example of a filled credential configuration form in YepCode:

FTP Snippets available in YepCode editor

note

The title is the triggering text for YepCode to autocomplete the script.

Integration

New integration from credential
const ftpClient = yepcode.integration.ftp('credential-slug');
New integration from plain authentication data (username and password)
const Client = require('ftp');
const ftpClient = new Client();
ftpClient.connect({
host: 'hostname',
user: 'user',
password: 'password'
})

Directory Listing

Directory listing

ftpClient.on('ready', function() {
ftpClient.list(function(err, list) {
if (err) throw err;
console.dir(list);
ftpClient.end();
});
});

Retrieve a File

Retrieve a file

ftpClient.on('ready', function() {
ftpClient.get('readme.txt', function(err, stream) {
if (err) throw err;
stream.once('close', function() { ftpClient.end(); });
stream.pipe(fs.createWriteStream('foo.local-copy.txt'));
});
});

Upload Data

Upload data from stream to remote server
const Stream = require('stream');
const readableStream = new Stream.Readable({
// Create your readable stream
read() {}
});

ftpClient.on('ready', function() {
ftpClient.put(readableStream, 'remoteDirPath', function(err) {
if (err) throw err;
ftpClient.end();
});
});

Delete a File

Delete a file on the remote server
ftpClient.on('ready', function() {
ftpClient.delete('remoteDirPath', function(err) {
if (err) throw err;
ftpClient.end();
});
});