Search code examples
javaftpapache-minaftp-server

Restrict accesible files and directories on Apache MINA FtpServer


I've adopted Apache FtpServer as a library of my file sharing app. However I expose that I can set the permission of files/directories.

e.g. I have many files/directories under home directory, but I just want to make only the ~/A/, ~/B/, ~/c.txt and ~/d.mp4 to be accessible via FTP connection.

Obviously it is not a good idea to make a temporary director as client root and copy files into, but there seems to be no built-in solution of Apache FtpServer.

Currently I am considering about implementing a FtpFile class for myself, but I'm still confused and hesitating.


Solution

  • Create your own implementation of the FileSystemFactory.

    Or derive your implementation from the default NativeFileSystemFactory. And change the createFileSystemView method to return only the entries you want.