JAVA FTPClient 질문입니다
조회수 339회
접속까진 성공했는데 FTPClient의 listNames나 listFiles, 파일을 다운로드 하는거까지 5분이 넘도록 넘어가지 않습니다.
FTP 서버의 video폴더에 있는 동영상 파일 중 하나를 제 로컬 경로에 저장하려고 합니다.
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
FTPClient client = new FTPClient();
String path = "C:/etc";
File folder = new File(path);
String filename = "CH120210512141433.mp4";
File f = new File(path, filename);
if(!folder.exists()) {
try {
folder.mkdir();
System.out.println("폴더 생성");
} catch(Exception e) {
e.printStackTrace();
}
} else {
System.out.println("폴더가 이미 존재");
}
try {
client.setControlEncoding("UTF-8");
client.connect("IP", PORT);
int resultCode = client.getReplyCode();
System.out.println("resultCode: " + resultCode);
if(client.login("svr", "password")) {
System.out.println("접속 성공");
} else {
client.disconnect();
System.out.println("접속 실패");
return "home";
}
client.setFileType(FTP.BINARY_FILE_TYPE);
client.changeWorkingDirectory("/video");
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(f));
boolean isSuccess = client.retrieveFile(filename, bos);
if(isSuccess) {
System.out.println("파일 다운로드 성공");
} else {
System.out.println("파일 다운로드 실패");
}
bos.close();
} catch(Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
return "home";
}
이렇게 하니 콘솔에 접속성공까지 잘 뜨고 제 로컬 폴더에 파일이 생성까지는 됐는데 계속 0KB라고만 뜹니다(다운 받으려는 동영상 파일은 7500KB 정도입니다).
왜 안 되는지 이유라도 알고싶습니다.
댓글 입력