SFTP Connection

Note

SFTP connection is available since Process17.0.0

SFTP Connection SFTP Connection

To set up a connection to a server :

  1. From the connection properties form, fill in the definition of the connection: the label, possibly a description, the connection’s attachment organization and the System name.

  2. Enter the connection settings :

    • Hostname
    • Port Number: The default port for an FTP connection is 22. The field is initialized to this value, but you can change it if needed
    • Connection time out : expressed in seconds and the field is initialized to 30 seconds, but you can change it if needed
    • Strict Host Key Check : In some cases, it may be convenient to disable the automatic addition of the host key of an SSH server when connecting to it. This is especially useful if you use VMs at home and reinstall them often.
    • Login or ID by which Process will connect to the server
    • Server login password by which Process will connect to the server
    • Base folder : path to the desired base folder

Example: agent listing the files in a folder

package com.axemble.vdoc.core.agents;

import com.jcraft.jsch.ChannelSftp;

import java.util.Vector;

import com.axemble.vdoc.VDocManagers;
import com.axemble.vdoc.connector.domain.ConnectionDefinition;
import com.axemble.vdoc.sdk.agent.base.BaseAgent;

public class TestAgent extends BaseAgent
{
	
	@Override
	protected void execute()
	{
		ConnectionDefinition<ChannelSftp> connectionDomain = VDocManagers.getConnectorManager().getConnectionDefinitionByName("SFTPTest");
		ChannelSftp channelSftp = connectionDomain.getConnection();
		try {
			Vector<ChannelSftp.LsEntry> list = channelSftp.ls("*");
			for(ChannelSftp.LsEntry entry : list) {
				getReport().addInfo(entry.getFilename());
			}
		} catch (Exception e) {
			e.printStackTrace();
			channelSftp.disconnect();
		}
	}
}