Skip to content

Latest commit

 

History

History
101 lines (96 loc) · 2.62 KB

SFTP.md

File metadata and controls

101 lines (96 loc) · 2.62 KB

DOCS

SFTP

내용 준비중

kotlin example

  • simple
    FTP.sftp("test.rebex.net", 22, "demo", "password").open()
      .use { ftp ->
          println("sftp opened!!")
          println("pwd: ${ftp.pwd()}")
          ftp.listFiles().forEach { println("file: $it") }
          assert(true)
      }
  • with custom options
    FTP.sftp("test.rebex.net", 22, "demo", "password")
      .beforeConnect { it.timeout = 120000; }
      .open()
      .use { ftp ->
        println("sftp opened!!")
        println("pwd: ${ftp.pwd()}")
        ftp.listFiles().forEach { println("file: $it") }
        assert(true)
      }
  • public key
    Ftp.sftp("public-key.test.com", 22)
      .userPublicKey("demo", "/user/.ssh/id_rsa")
      .beforeConnect { it.timeout = 120000; }
      .open()
      .use { ftp ->
          println("sftp opened!!")
          println("pwd: ${ftp.pwd()}")
          ftp.listFiles().forEach { println("file: $it") }
          assert(true)
      }

java example

  • simple
    try (Ftp ftp = Ftp.sftp("test.rebex.net", 22, "demo", "password").open()) {
      System.out.println("sftp opened!!");
      System.out.println("pwd: " + ftp.pwd());
      ftp.listFiles().forEach( it -> System.out.println("file: " + it) );
      assert(true);
    }
  • with custom options
    try (
        Ftp ftp = 
            Ftp
                .sftp("test.rebex.net", 22, "demo", "password")
                .beforeConnect { it.timeout = 120000; }
                .open()
    ) {
        System.out.println("sftp opened!!");
        System.out.println("pwd: " + ftp.pwd());
        ftp.listFiles().forEach( it -> System.out.println("file: " + it) );
        assert(true);
    }
  • public key
    try (
      Ftp ftp = 
          Ftp
              .sftp("public-key.test.com", 22)
              .userPublicKey("demo", "/user/.ssh/id_rsa")
              .open()
    ) {
        System.out.println("sftp opened!!");
        System.out.println("pwd: " + ftp.pwd());
        ftp.listFiles().forEach( it -> System.out.println("file: " + it) );
        assert(true);
    }

참고