I set up an FTPS server using Apache MINA. By overriding the default ftplet I can detect when a client starts uploading a new file to the server. I want to redirect the transfer to an S3 database, instead of having the file written in disk. The ftplet documentation in the MINA project states (https://mina.apache.org/ftpserver-project/ftplet.html) that
We can get the data input stream from request
But I cannot find how to get that stream from the two arguments.
Furthermore, in the FAQ there is a code example where a download is obtained from a database, by overriding the onDownloadStart method (https://mina.apache.org/ftpserver-project/faq.html#how-can-i-send-binary-data-stored-in-a-database-when-the-ftp-server-gets-the-retr-command):
public FtpletEnum onDownloadStart(FtpSession session, FtpRequest request,
FtpReplyOutput response) throws FtpException, IOException {
....
However, I am using the latest MINA version (mina-core 2.0.16, ftplet-api 1.1.1, ftpserver-core 1.1.1) and that method does not include the third argument. Has this changed in the latest versions??
The
onDownloadStartexample you're referring to seems to be out of date. For starters, theFtpletEnumclass used was part of an early version offtplet-api. Newer versions don't have it anymore. At least I was not able to find it.Despite that, it's still possible to get the uploaded file from the client. You can ask for a
DataConnectionfrom the session, when overridingDefaultFtplet'sonUploadStartmethod.Keep in mind that you might also have to notify the client with response codes if your
onUploadStartmethod returns SKIP. From Ftplet docs