THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
FtpServer is designed to be easily embedded into your application. Getting a basic server up and running is as simple as
Code Block |
---|
FtpServerFtpServerFactory serverserverFactory = new FtpServerFactory(); FtpServer server = serverFactory.createServer(); // start the server server.start(); |
...
Now, let's configure the port on which the default listener waits for connections.
Code Block |
---|
FtpServer server FtpServerFactory serverFactory = new FtpServerFtpServerFactory(); ListenerFactory factory = new ListenerFactory(); // set the port of the listener factory.setPort(2221); // replace the default listener server.getListener serverFactory.addListener("default"), factory.setPortcreateListener(2121)); // start the server FtpServer server = serverFactory.createServer(); server.start(); |
Now, let's make it possible for a client to use FTPS (FTP over SSL) for the default listener.
Code Block |
---|
FtpServer server FtpServerFactory serverFactory = new FtpServerFactory(); ListenerFactory factory = new FtpServerListenerFactory(); // set the port of the default listener server.getListener("default"). factory.setPort(2221); // define SSL configuration SslConfiguration SslConfigurationFactory ssl = new SslConfigurationSslConfigurationFactory(); ssl.setKeystoreFile(new File("mykeystoresrc/test/resources/ftpserver.jks")); ssl.setKeystorePassword("secretpassword"); // set the SSL configuration for the listener server.getListener factory.setSslConfiguration(ssl.createSslConfiguration()); factory.setImplicitSsl(true); // replace the default listener serverFactory.addListener("default", factory.createListener()).setSslConfiguration(ssl.createSslConfiguration; PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory(); userManagerFactory.setFile(new File("myusers.properties")); serverFactory.setUserManager(userManagerFactory.createUserManager()); // start the server FtpServer server = serverFactory.createServer(); server.start(); |
There you have it, that's the basics that you usually need. For more advanced features, have a look at our configuration documentation.