Sample code for 30+ languages & platforms
React Native

Use Explicit FTP over TLS

See more FTP Examples

Demonstrates how to connect to an FTP server using explicit FTP over TLS.

Chilkat React Native Downloads

React Native
import { Ftp2 } from '@chilkat/react-native'

async function chilkatExample() {
  // This example requires the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  const ftp = new Ftp2();

  ftp.hostname = 'ftp.your-ftp-server.com';
  ftp.username = 'ftpAccountLogin';
  ftp.password = 'ftpAccountPassword';

  // Indicate that the "AUTH TLS" command should be use to convert the connection to TLS
  // after the initial TCP connection to port 21 is established.
  ftp.authTls = true;

  // Connect and convert the connection to TLS automatically.
  try {
    await ftp.connectOnlyAsync();
  } catch {
    console.log(ftp.lastErrorText);
    return;
  }

  try {
    await ftp.loginAfterConnectOnlyAsync();
  } catch {
    console.log(ftp.lastErrorText);
    return;
  }

  console.log('TLS connection established and successfully authenticated.');
}