내가 좋아하는 이미지 갤러리 소프트웨어 인 안드로이드 용 이미지 파일 업 로더를 작성 중이며 FTP를 사용하고 있습니다. past stack overflow questions을 기반으로 한 ftp 라이브러리로 Apache-Commons Net FTP를 사용하기 시작했습니다. 그래서 같이 : 내가 로그인지고있어 로그에서 볼Android에서 InputStream이 작동하지 않는 이유는 무엇입니까?
FTPClient ftp = new FTPClient();
try{
ftp.connect(host);
Log.i(TAG,"we connected");
if(!ftp.login(user,pass)){
ftp.logout();
//TODO: alert user it didn't happen
return;
}
String replyStatus = ftp.getStatus();
Log.i(TAG,replyStatus);
int replyCode = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(replyCode))
{
ftp.disconnect();
//TODO: alert user it didn't happen
return;
}
Log.i(TAG,"we logged in");
ftp.changeWorkingDirectory(path);
ftp.setFileType(ftp.BINARY_FILE_TYPE);
for(int i = 0; i < contentUris.size(); i++){
Log.i(TAG,"uploading new file");
Uri stream = (Uri) contentUris.get(i);
//InputStream in = openFileInput(getRealPathFromURI(stream));
InputStream in =this.getContentResolver().openInputStream(stream);
BufferedInputStream buffIn=null;
buffIn=new BufferedInputStream(in);
ftp.setFileType(ftp.BINARY_FILE_TYPE);
boolean Store = ftp.storeFile("test.jpg", buffIn);
Log.i(TAG, "uploaded test");
}
ftp.disconnect();
}
catch(Exception ex){
//do something wise and smart and useful
}
, 나는 디렉토리를 변경할 수있어, 내가 업로드 할 때 내 디렉토리에 test.jpg를 얻을하지만, 0 바이트 크기 .
무엇을 제공합니까? 입력 스트림을 제대로 열지 못합니까? 어떻게 제대로 할 수 있습니까? 나는 충분한 정보를 제공하고 있지 않다 경우
알려주세요 - 문제가 당신이 수동 모드를 사용해야합니다, 활성 FTP 연결을 할 수 없다는 것입니다 같은 full code is also available on github