1

我正在为 Ftp 客户端使用https://github.com/akka/alpakka/tree/master/ftp/src这个库。我将文件的 url 作为路径。但正如我从代码实现中看到的,它们只支持函数中的 java.nio.file.Path。

val ftpSettings = FtpSettings(host, port, NonAnonFtpCredentials(userName, pass), passiveMode = true)
Ftp.fromPath("Path object", ftpSettings)

但是我没有本地文件。我只有文件的网址。是否有可能通过 url 获取文件?

4

2 回答 2

1

还有 2 个fromPath允许指定主机和凭据的重载。

  def fromPath(
      host: String,
      path: Path
  )(implicit ftpLike: FtpLike[FtpClient]): Source[ByteString, Future[IOResult]]

  def fromPath(
      host: String,
      username: String,
      password: String,
      path: Path
  )(implicit ftpLike: FtpLike[FtpClient]): Source[ByteString, Future[IOResult]]
于 2016-12-10T09:31:58.247 回答
0

最后,我发现了带有 url 的路径的用法。而不是使用整个 url,只需使用文件的路径。

Ftp.fromPath(Paths.get("/directory/fileName.txt"), ftpSettings)
于 2016-12-10T11:44:29.130 回答