Skip to content

qie.writeSFTPFile

Signature: qie.writeSFTPFile(host, port, path, binary, passive, ftpParameters, userName, password, data, sshKeyName*)

Returns: void

Writes the data to an FTP endpoint.

Note

QIE uses version 4.22.0 of Apache Camel. (See this article for available parameters).

Parameters

Type Name Description Default
String host hostname or ip address for the ftp server
Integer port the port number to use
String path {path}/{filename.extension} to write the file to. Use ".{no-extension}" to write to a file without an extension.
Boolean binary transfer data using binary protocol
Boolean passive use passive transfer mode (usually true)
String ftpParameters additional custom camel ftp parameters to be used by this connection. (Format: {key}={value}\n{key2}={value2}...)
String userName username to use for this connection
String password password to use for this connection
byte[], String, File data data to be written to ftp endpoint
String sshKeyName* (optional) the name of the ssh key stored as a private certificate key null

Example

// WRITE FILE:
// Write data to a file on an SFTP server.
// If the file already exists, an error may be thrown depending on server configuration.

try {
    qie.writeSFTPFile(
        'sftp.example.com',            // host: SFTP server hostname
        22,                            // port: SFTP port
        'mine.txt',                    // path: remote file path (path/filename.ext)
        false,                         // binary: transfer mode
        true,                          // passive: passive mode
        '',                            // ftpParameters: additional Camel params
        'interfaceUser',               // userName: login username
        'yourPassword',                // password: login password
        'More data to go in mine.txt.' // data: content to write
    );
} catch (error) {
    qie.warn(error); // Useful if the file already exists or connection fails
}