Passer au contenu principal


Adaptive Insights French

Set Up and Configure an SFTP

Explains how to connect to an SFTP server and upload, download and perform various operations on files.

You can create a client to connect to your Secure File Transfer Protocol (SFTP) server and perform various operations on your files. This article explains how to add an SFTP Connection to the Custom Cloud Data Source (CCDS) and how to include the SFTP connection in your script.  See  Set up PGP Encryption for information about encrypting and decrypting your files.

Before you Begin

How You Get There

Compass.png Depuis nav menu, accédez à Integration > Intégrations de conception

Set Up and Configure an SFTP

Create a new SFTP connection

  1. Create an SFTP Connection from the Credentials pane in Design Integrations. 
  2. Enter a name for the connection and click Create.
  3. In your connection form, enter the host expression. 
  4. Choose your authentication method. 
    • For Private Key authentication, no password is required.
    • For Basic authentication, enter a password. 
  5. For Private key authentication, send the Public Key to the client server administrator for installation.

  6. Select Test Connection for the first time.

For Private Key or Basic authentication:

  • When you select Test Connection for the first time, the Fingerprint field populates. This enables server verification for future connections. The client server administrator can verify the Fingerprint confirming that you are connected to the right server.

  • After running Test Connection for the first time, click your SFTP connection in the Credentials pane to reload the connection and view the fingerprint field. 

  • When you select Test Connection or use the SFTP connection in a script, the fingerprint from the server must match or the connection fails.

Select your Custom Cloud Data Source 

Select a  CCDS or create a CCDS from Data Sources in Design Integrations.  

Add an SFTP Connection to the Custom Cloud Data Source

  1. Select the Designer Settings tab for your CCDS.
  2. Drag and drop the SFTP Connection parameter from Additional Settings in the Settings Component pane. 
  3. Configure the SFTP connection in the Designer Settings tab. The setting name is the handle you will use inside your script. For example, 'sftpserver'.

Add the SFTP Connection in your Script

  1. Create a client using ai.sftp.createClient() and provide the name of your SFTP setting.  For example: const client = ai.sftp.createClient('mysftp'). After connecting successfully, a client object is created. 
  2. Test your Connection from the Actions pane to run your script. You can find find test results of your script in Logs in the Actions pane.

SFTP methods for File Upload and Download

Use the following methods to create a client, upload and download encrypted files to an SFTP server and encrypt or decrypt them with PGP.  See ai.sftp

  • createClient(sftpConnection)    

client = ai.sftp.createClient('mysftp');

  • uploadFile(Writer,  uploadedFileName)


  • downloadFile(filename)


  • Disconnect the client


  • Free the system resources consumed by the file Reader object. 


Example to Connect and Download files from an SFTP server

function testConnection(context) {
    let client;
    try {
        client = ai.sftp.createClient('mysftp');
    catch(e) {
        ai.log.logError('An error occurred connecting to the server: ' + e);
        return false;
    finally {
        if (client) client.disconnect();
    return true;
function importData(context) {
    const rowset = context.getRowset();
    const client = ai.sftp.createClient('mysftp');
    const reader = client.downloadFile('./someData.csv');
    try {
        let line = reader.readLine();
        while (line)
            let cells = line.split(',');
            line = reader.readLine();
    catch(e) {
        ai.log.logError('An error occurred downloading the file: ' + e);
    finally {


  • Cet article vous a été utile ?