문제
Java 프로젝트에서 Apache의 FTPClient 및 FTPServer 라이브러리를 사용합니다.서버와 클라이언트는 동일한 시스템에 있습니다.
내 ftpserver는 인터넷과 관련된 로컬 서버로 가정됩니다.클라이언트에서 FTPServer에 연결할 수 있습니다 (나는 회신 코드로 230을 얻을 수 있음)하지만 아무것도하지 않는 것 같습니다.파일을 저장하거나 검색 할 수 없습니다.
나는이 문제와 관련된 거의 모든 질문을 읽었지 만, 다른 질문을 한 사람들은 간단한 파일을 보내고 PDF 등과 같은 파일을 보내는 데 어려움을 겪었으며 텍스트 파일을 보내거나 검색해야합니다.
모든 제안?
FTPClient client = new FTPClient();
String host = "mypc";
String Name = "user";
String Pass = "12345";
client.connect(host);
client.login(Name,Pass);
System.out.println("Reply Code: " +client.getReplyCode());
File file = new File("C:\\.....myfile..txt");
FileInputStream in = new FileInputStream("C:\\.....myfile..txt");
boolean isStored = client.storeFile("uploadedfile.txt", in);
in.close();
client.logout();
System.out.println("isStored: " +isStored);
.
실제 경로 이름을 넣지 않았습니다.그것은 거짓, 예외 없음 등을 반환합니다. 이것은 동일한 기계에 있기 때문일 수 있습니까?
편집 : FTPServer에 파일을 보낼 수있는 쓰기 권한이 필요했습니다.기본적으로 사용자는 사용자에게 쓰기 권한을 부여하지 않습니다.Apache의 FTPServer 라이브러리를 사용하여 사용자에게 권한을 쓸 수 있습니까?
해결책
Problem Solved: This is how to give a user write permission. I added this snippet to server side and it worked.
List<Authority> auths = new ArrayList<Authority>();
Authority auth = new WritePermission();
auths.add(auth);
user.setAuthorities(auths);
There's term Authority
written in this symbol -> < >
after List
and ArrayList
in the first line. Site doesn't see words in <>
symbol.