Scala zio for ftp

187 Views Asked by At

I want to do sftp in zio. I have this piece of code.

  val settings = SecureFtpSettings("anomymous", 22, FtpCredentials("anomymous", "anomymous"))
  val sftpLayer = secure(settings)

 override def run(args: List[String]): URIO[ZEnv, ExitCode] = program.exitCode

  val program =
    for {
      files   <- connect(settings).use(_.readFile(filename).runCollect)
      lsStr   <- UIO(files.fold(new StringBuilder()){ (sb, ss) => s"${sb} ${ "" + ss}" }.toString)
      _       <- putStr(lsStr)
    } yield ()

When I try to read the contents of files (Chunk[Byte]), I get the output as bytes. Can anyone tell me a way of parsing a Chunk[Byte] to Strings in zio and save the contents of the file.

0

There are 0 best solutions below