Skip to main content

FTP

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

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 FTP server.

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

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

FTP snippets available in 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 local system to remote server
const Stream = require('stream');
const readableStream = new Stream.Readable({
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();
});
});