Thanks for the additional information, Dennis. Your explanation sounds a lot like what im going through right now. I was able to make some minor breakthroughs that look promising. Fortunately, in my case, I'm only looking to implement a 'read-only' SFTP implementation, so it lowers the bar quite a bit. Though yes, many methods are not needed... might be worth creating a wrapper that narrows it down to the minimal methods needed.
I also struggled for a very long time with the file permission aspect of creating an FTP FileSystem. It seems that MINA likes to use Path to create a 'File' in the base of "basic" permissions, which will obviously fail for any FS which is virtual. I was able to get around it by adding "posix" but I also successfully worked around by returning an extended 'File' class which just exists to return the true/false values needed. Seemed like something MINA could have handled a bit better though. As for implementing the SeekableByteChannel, I just wrapped the FTP InputStream in a JDK provided ReadableByteChannel wrapper and then wrapped that with a dummy proxy which does nothing in the methods added by 'seekable' which were not mappable. I figured it was only necessary for file resume, and it seems I was correct -- and we can live without resume. Might be able to later add a one-time-seek using the FTP resume commands -- guessing that it only needs the seek to specify a starting point for resuming downloads. Best Will -----Original Message----- From: Dennis van der Laan <[email protected]> Sent: Friday, December 8, 2023 6:42 AM To: Guillaume Nodet <[email protected]> Cc: [email protected] Subject: Re: Implementing a 'filesystem' module in MINA to bridge with an Apache commons-net FTPClient WARNING: This email originated from outside of GE HealthCare. Please validate the sender's email address before clicking on links or attachments as they may not be safe. The SftpFileSystem is a wrapper around an SFTP connection. In the case of Will's project you need a wrapper around the FTP connection as the 'local' filesystem of the SFTP server. Cheers, Dennis On Fri, 8 Dec 2023 at 13:12, Guillaume Nodet <[email protected]> wrote: > Maybe I misunderstand something, but Mina SSHD *provides* a > FileSystemFactory that completely supports SFTP. > Why would you want to re-implement it ? > See > > https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith > ub.com%2Fapache%2Fmina-sshd%2Fblob%2Fmaster%2Fdocs%2Fsftp.md%23using-s > ftpfilesystemprovider-to-create-an-sftpfilesystem&data=05%7C01%7CWill. > Soderberg%40gehealthcare.com%7C451a29d250544f62fc7308dbf7eb290d%7C9a30 > 9606d6ec4188a28a298812b4bbbf%7C0%7C0%7C638376361627715248%7CUnknown%7C > TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVC > I6Mn0%3D%7C3000%7C%7C%7C&sdata=Br9ythbx8No7r6NsG6udAoAcS4hg2PeVXyg%2Fb > gQb72w%3D&reserved=0 > > Guillaume > > Le jeu. 7 déc. 2023 à 21:00, Soderberg, Will < > [email protected]> a écrit : > > > Hello, > > > > Haven't had much luck finding answers on stackoverflow etc so trying > here. > > > > I'm working on a project which uses both Apache MINA and Apache > > commons-net FTPClient to create a protocol adapter that provides an > > SFTP wrapper to access FTP servers (which cannot be upgraded to SFTP > > for > complex > > reasons). > > > > I've been able to get authentication and file transfer working by > > hardcoding the paths, but what I'm struggling with is file+folder > listing. > > FTPClient has a very simple API for this, but MINA seems to require > > an extremely sophisticated implementation of > > java.nio.file.FileSystem, FileSystemFactory, Path, etc to make this > > work. I was hoping that implementing > > SftpFileSystemAccessor.openDirectory would be enough, but > when > > setting breakpoints I'm not seeing that method be called in the way > > I > would > > expect for it to be the solution. > > > > Am I overthinking this? Which approach is correct for what I'm > > looking > to > > do? I can't provide a very complete implementation of FileSystem > > due to the limitations of FTP, but it seems like MINA only really > > uses a few methods from it anyway. > > > > > > Thank you > > Will > > > > > -- > ------------------------ > Guillaume Nodet > -- D.G. van der Laan, MSc Sr. Software Engineer, team Content Management System & Online Development Center for Information Technology +31 (0)50 363 9273 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
