2014-05-15 4 views
0

Android에서 FTP로 이미지를 업로드하는 방법은 하나입니다. 찍은 사진을 업데이트하려고하면 FTP 파일에서 아무 것도 볼 수 없습니다. 그것은 생성하고 크기는 괜찮지 만 아무것도 포함하지 않습니다. 그 때 나는 하나 개의 작은 이미지를 업로드하려고 다음은 결과입니다 사진을 Android에서 FTP로 업데이트하는 중 오류가 발생했습니다.

Random image to upload

(랜덤 이미지 업로드)

Random image uploaded

(이미지 업로드)

코드 :` Sender 클래스 AsyncTask를 확장합니다. { 파일 사진; 공개 발신자 (파일 사진) { this.photo = 사진;

} 


    protected String doInBackground(String... params) 
    { 
     FTPClient ftpClient = new FTPClient(); 
     try { 
      ftpClient.connect(InetAddress.getByName("ftp.fercode.com")); 
      ftpClient.login(xxx","xxx"); 
      Boolean result = ftpClient.changeWorkingDirectory("/img"); 
      Log.e("existeix carpeta?",result.toString()); 


     } catch (IOException e1) { 
      // TODO Auto-generated catch block 
      e1.printStackTrace(); 
     } 

     InputStream srcFileStream=null; 
     try { 

      srcFileStream = new FileInputStream(photo.getAbsolutePath()); 

     } catch (FileNotFoundException e1) { 
      // TODO Auto-generated catch block 
      e1.printStackTrace(); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 

     try { 
      //ftpClient.stor(photo.getAbsolutePath()); 

      boolean status = ftpClient.storeFile("/img/imagePrueba.jpeg", 
        srcFileStream); 
      Log.e("Status", String.valueOf(status)); 
      srcFileStream.close(); 
     } catch (FileNotFoundException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 


     // TODO Auto-generated method stub 


     return null; 

    } 
    @Override 
    protected void onPreExecute() 
    { 
     super.onPreExecute(); 

    } 

    @Override 
    protected void onPostExecute(String result) 
    { 
     // TODO Auto-generated method stub 
     super.onPostExecute(result); 

    } 
}` 

내가 뭘 잘못하고있어? 많이 Thx

답변

0

내가 ASCII와 같은 이진 이미지를 업로드하기 때문에 이런 일이 일어난다. 구성 매개 변수 일뿐입니다.

ftpClient.setFileType (FTP.BINARY_FILE_TYPE);

관련 문제