사용자 도구

사이트 도구


java:ftp

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
마지막 판 양쪽 다음 판
java:ftp [2019/03/17 11:31]
kwon37xi
java:ftp [2019/03/22 15:20]
kwon37xi [apache commons net FTPClient]
줄 2: 줄 2:
   * [[:java|Java]] 에서 FTP 프로토콜 사용은 [[https://commons.apache.org/proper/commons-net/|apache commons net]] 으로 할 수 있다.   * [[:java|Java]] 에서 FTP 프로토콜 사용은 [[https://commons.apache.org/proper/commons-net/|apache commons net]] 으로 할 수 있다.
   * [[https://mvnrepository.com/artifact/commons-net/commons-net|commons-net maven repo]]   * [[https://mvnrepository.com/artifact/commons-net/commons-net|commons-net maven repo]]
 +
 +===== apache commons net FTPClient =====
 +  * [[https://stackoverflow.com/a/8154539/1051402|요청 결과 상태 확인]] ''FtpClient#getReplyCode()''
 +  * ''FTPReply'' 로 의미 확인 가능.
 +  * [[https://en.wikipedia.org/wiki/List_of_FTP_server_return_codes|FTP Server Return Codes]] 참조해서 확인
 +  * ''FtpClient.setFileType(FTP.BINARY_FILE_TYPE);'' : binary 전송
 +===== Passive Mode =====
 +
 +===== MockFtpServer =====
   * [[http://mockftpserver.sourceforge.net/|MockFtpServer]] FTP 서버를 mocking하여 테스트를 할 수 있다.   * [[http://mockftpserver.sourceforge.net/|MockFtpServer]] FTP 서버를 mocking하여 테스트를 할 수 있다.
  
 +<code java>
 +public class FtpClientIntegrationTest {
 + 
 +    private FakeFtpServer fakeFtpServer;
 + 
 +    private FtpClient ftpClient;
 + 
 +    @Before
 +    public void setup() throws IOException {
 +        fakeFtpServer = new FakeFtpServer();
 +        fakeFtpServer.addUserAccount(new UserAccount("user", "password", "/data"));
 + 
 +        FileSystem fileSystem = new UnixFakeFileSystem();
 +        fileSystem.add(new DirectoryEntry("/data"));
 +        fileSystem.add(new FileEntry("/data/foobar.txt", "abcdef 1234567890"));
 +        fakeFtpServer.setFileSystem(fileSystem);
 +        fakeFtpServer.setServerControlPort(0);
 + 
 +        fakeFtpServer.start();
 + 
 +        ftpClient = new FtpClient("localhost", fakeFtpServer.getServerControlPort(), "user", "password");
 +        ftpClient.open();
 +    }
 + 
 +    @After
 +    public void teardown() throws IOException {
 +        ftpClient.close();
 +        fakeFtpServer.stop();
 +    }
 +}
 +</code>
  
 ===== 참조 ===== ===== 참조 =====
java/ftp.txt · 마지막으로 수정됨: 2019/03/22 17:17 저자 kwon37xi