如何使用akka.stream.alpakka.ftp列出scala的sftp文件?

krugob8w  于 2023-03-08  发布在  Scala
关注(0)|答案(1)|浏览(170)

在我的Scala代码中,我有:

val ftpApi: FtpApi[SSHClient, SftpSettings]

val futureResult = ftpApi.ls(basePath = path, connectionSettings = settings)

这将生成以下输出:

11:53:36.875 [sshj-Reader-/200.13.144.60:181] DEBUG net.schmizz.sshj.transport.TransportImpl - Setting active service to null-service
11:53:36.875 [sshj-Reader-/200.13.144.60:181] DEBUG net.schmizz.concurrent.Promise - Setting <<transport close>> to `SOME`
11:53:36.875 [sshj-Reader-/200.13.144.60:181] DEBUG net.schmizz.sshj.transport.Reader - Stopping
[ERROR] [02/27/2023 11:53:36.876] [default-akka.actor.default-blocking-io-dispatcher-21] [akka://default/system/Materializers/StreamSupervisor-0/flow-0-2-sFtpBrowserSource] Error during postStop in [akka.stream.alpakka.ftp.impl.FtpBrowserGraphStage$$anon$1-sFtpBrowserSource]: Broken transport; encountered EOF
net.schmizz.sshj.connection.ConnectionException: Broken transport; encountered EOF
    at net.schmizz.sshj.connection.ConnectionException$1.chain(ConnectionException.java:32)
    at net.schmizz.sshj.connection.ConnectionException$1.chain(ConnectionException.java:26)
    at net.schmizz.concurrent.Promise.deliverError(Promise.java:95)
    at net.schmizz.concurrent.Event.deliverError(Event.java:74)
    at net.schmizz.concurrent.ErrorDeliveryUtil.alertEvents(ErrorDeliveryUtil.java:34)
    at net.schmizz.sshj.connection.channel.AbstractChannel.notifyError(AbstractChannel.java:239)
    at net.schmizz.sshj.connection.channel.direct.SessionChannel.notifyError(SessionChannel.java:229)
    at net.schmizz.sshj.common.ErrorNotifiable$Util.alertAll(ErrorNotifiable.java:35)
    at net.schmizz.sshj.connection.ConnectionImpl.notifyError(ConnectionImpl.java:261)
    at net.schmizz.sshj.transport.TransportImpl.die(TransportImpl.java:588)
    at net.schmizz.sshj.transport.Reader.run(Reader.java:66)
Caused by: net.schmizz.sshj.transport.TransportException: Broken transport; encountered EOF
    at net.schmizz.sshj.transport.Reader.run(Reader.java:58)

我期望这将列出sftp中的文件。

pn9klfpd

pn9klfpd1#

我看到你有FtpApi,但是有SftpSettings,你可以直接用
对于FTP:

val source: Source[FtpFile, NotUsed] = Ftp.ls(sourcePath, ftpSettings)

对于SFTP:

val source: Source[FtpFile, NotUsed] = Sftp.ls(sourcePath, sftpSettings)

Alpakka(S)FTP实现有一些怪癖,不管怎样,this working SFTP example是一个展示可能性的尝试。

相关问题