I have built a FTP Server in android app using https://mina.apache.org/ftpserver-project/documentation.html. I need to render a html page from Assets as my home page. But it is always listing a directory.
connectionConfigFactory.isAnonymousLoginEnabled = true
connectionConfigFactory.maxLogins = 1
connectionConfigFactory.maxThreads = 1
ftpServerFactory.connectionConfig = connectionConfigFactory.createConnectionConfig()
ftpServer = ftpServerFactory.createServer()
listenerFactory.setPort(2121)
ftpServerFactory.addListener("default", listenerFactory.createListener())
ftpServerFactory.ftplets.put(FTPLetImpl::class.java.getName(), FTPLetImpl())
val files =
File(Environment.getExternalStorageDirectory().path + "/users.properties")
if (!files.exists()) {
try {
files.createNewFile()
} catch (e: IOException) {
e.printStackTrace()
}
}
userManagerFactory.setFile(files)
userManagerFactory.setPasswordEncryptor(SaltedPasswordEncryptor())
val um: UserManager = userManagerFactory.createUserManager()
val user = BaseUser()
user.name = "anonymous"
user.enabled = true
val home =
Environment.getExternalStorageDirectory().path + "/Test"
user.homeDirectory = home
val auths: MutableList<Authority> =
ArrayList()
val auth: Authority = WritePermission()
val auth1: Authority = ConcurrentLoginPermission(MAX_CONCURRENT_LOGINS,MAX_CONCURRENT_LOGINS_PER_IP)
val auth2: Authority = TransferRatePermission(Integer.MAX_VALUE, Integer.MAX_VALUE)
auths.add(auth)
auths.add(auth1)
auths.add(auth2)
user.authorities = auths
try {
ftpServerFactory.userManager.save(user)
} catch (e1: FtpException) {
e1.printStackTrace()
}
Even though I set the user home directory as Html page. It gets downloaded in the browser & not rendering it