Create Ftplet for Apache FtpServer in Kotlin

Job ID: 33297191

Budget: $30 – $250 USD

This will be a testing tool and proof-of-concept. We need source code for a tiny server for the FTP image-upload interface built into modern mirrorless and DSLR cameras, in particular the Canon EOS 5D Mark IV. If this works, it will become the heart of a far larger image processing tool implemented in KMM. This is a new Kotlin 1.6 project with no legacy code to interface with. Your code may be a smiple standalone file.

## References

* Ftplet 1.2 API: https://mina.apache.org/ftpserver-project/ftplet.html
* Clickt 3.4 API: https://ajalt.github.io/clikt/
* SLF4J 2.0 manual: https://www.slf4j.org/manual.html

## Requirements

Only one mode is required: foreground mode. This is not a daemon.

The tool should accept a "--port" option, start a FtpServer on that port, and then let it run until cancelled by Ctrl-C.

For now, only classic FTP needs to be supported, not SFTP, SSL/TLS, or other more secure protocols.

Internally, the Ftplet should, via SLF4J, log to stdout the client connections, disconnections, upload starts, and upload ends.
Note well that SLF4J 2.0 radically changed the logger backend configuration method, and this could be problematic. No special error handling is needed beyond what FtpServer already does.
Internally, the command line options should be parsed with Clickt.

Target platforms are Google Android 11 (Red Velvet Cake) on arm64 and Debian GNU/Linux 11 (Bullseye) on amd64.

Unit tests are not required, but if included, kotest is preferred over JUnit5. You may test the functionality with ordinary command-line tools (ftp, lftp, wget, wput, etc.) -- a DSLR is not required on your end.

## Appendix

Before coding, this script can be used as a sanity check of the Kotlin environment.

#!/usr/bin/env kscript
//DEPS org.apache.ftpserver:ftpserver-core:1.1.3
//DEPS org.slf4j:slf4j-simple:2.0.0-alpha6

import org.apache.ftpserver.FtpServerFactory
import org.apache.ftpserver.listener.ListenerFactory
val serverFactory = FtpServerFactory()
val listenerFactory = ListenerFactory()
listenerFactory.setPort(1234)
serverFactory.addListener("default", listenerFactory.createListener())
val server = serverFactory.createServer()
server.start()
println("Success!")
Related categories: Mobile App Development Kotlin