Sidebar

Is there a way to SFTP a file in a mapping function?

0 votes
931 views
asked Apr 24, 2014 by ben-s-7515 (12,320 points)
Is it possible to send a file via SFTP in a mapping function?

2 Answers

0 votes
 
Best answer

In .44 we have added qie functions to handle this:

qie.countSFTPEndpoint('host', port, 'path', binary, passive, 'ftpParameters', 'userName', 'password');
qie.readSFTPFile('host', port, 'path', deleteFile, 'archivePath', binary, passive, 'ftpParameters', 'userName', 'password', timeout);
qie.writeSFTPFile('host', port, 'path', binary, passive, 'ftpParameters', 'userName', 'password', data);
qie.listSFTPEndpoint('host', port, 'path', binary, passive, 'ftpParameters', 'userName', 'password');

answered Jul 30, 2018 by brandon-w-8204 (33,270 points)
selected Aug 14, 2020 by brandon-w-8204
+1 vote

To SFTP a file in a mapping node, you can use the following code:

 

importPackage(com.jcraft.jsch);
 
var ssh = new com.jcraft.jsch.JSch();
var session = ssh.getSession("{user}", "{host}", 22);
session.setConfig("StrictHostKeyChecking", "no");
session.setPassword("{password}");
session.connect();
var channel = session.openChannel("sftp");
channel.connect();
channel.put("{source_file}", "{destination_file}");
// channel.rm("{remote_file}"); // removes the file
channel.exit();
session.disconnect();
 
answered Apr 24, 2014 by ben-s-7515 (12,320 points)
asked Jul 7, 2015 by (170 points) How to Create Dated Folder in SFTP
...