Making SFTP requests from a Vapor application?

I'm working on a server application that's deployed to Heroku. The application is supposed to fetch, periodically, a data dump from a remote service and then transform the data into something useful. My problem, here, is that the remote service wants to expose the data dump via SFTP.

I've looked for SFTP client packages for Swift and so far only found a pair of frameworks that rely on linking via Xcode, but that's not going to help my case. I also found this announcement for SwiftNIO-SSH, but haven't seen anything beyond another topic here where a person was developing an SFTP server.

Now, developing an SFTP client seems to me to be complicated enough to be well outside the scope of my current project. I would really like to be able to perform the file transfer from a worker thread in my Vapor application, so I thought I'd ask here, before I go down a different rabbit hole of figuring out how to do it with Perl or python and then adding a custom buildpack to install whatever supporting modules are required, and invoking the script from a worker thread via Process.run (all of which will definitely work the first time, with no problems).

So: is there a clean way to do this just in Swift, within my Vapor server? Could it be as simple as constructing a URL and invoking it?

Check out Citadel – Swift Package Index, it seems to offer what you're looking for.

4 Likes