FTP Connection

Note

FTP connection is available since Process17.0.0

FTP Connection FTP 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 21. 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
    • 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 org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;

import java.io.IOException;

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<FTPClient> connectionDefinition = VDocManagers.getConnectorManager().getConnectionDefinitionByName("FTPTest");
		FTPClient ftpClient = connectionDefinition.getConnection();
		try {
			FTPFile[] ftpFiles = ftpClient.listFiles("/");
			for (FTPFile ftpFile : ftpFiles) {
				getReport().addInfo(ftpFile.getName());
			}
			ftpClient.disconnect();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
}