SimpleFtpServer
Introduction
Hutool has encapsulated a simple FTP server component based on Apache FtpServer, which is mainly used in some testing scenarios or low-concurrency application scenarios.
Usage
Introducing FtpServer
<dependency>
<groupId>org.apache.ftpserver</groupId>
<artifactId>ftpserver-core</artifactId>
<version>1.1.1</version>
</dependency>Using FtpServer
- Starting an anonymous FTP service:
SimpleFtpServer
.create()
// This directory must exist
.addAnonymous("d:/test/ftp/")
.start();At this point, you can access it through the resource manager:
ftp://localhost- Customizing users:
BaseUser user = new BaseUser();
user.setName("username");
user.setPassword("123");
user.setHomeDirectory("d:/test/user/");
SimpleFtpServer
.create()
.addUser(user)
.start();