2015-01-05 32 views
0

我一直在尋找相當一段時間,找不到解決方案。 我試圖從我的電腦上傳文件到我的ftp服務器。但每次我嘗試,我只創建一個0kb文件。上傳後的Proftpd - 0kb文件

我試圖

  1. 夾在開啓防火牆斷開
  2. 搭配chmod -R 775
  3. 20不同版本的客戶端
  4. 被動傳輸模式
  5. 二進制文件類型的
  6. 二進制類型傳輸模式
  7. 使用最新的commons-n等libary(3.3)

相關:

0 kb file created once FTP is done in java

FTP a file to server, but it the result arrives with zero byte size

public static void goforIt(){ 
    FTPClient ftpClient = new FTPClient(); 
    ftpClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); 
    try { 

     ftpClient.connect("xxx.xxx.xxx.xx"); 

     ftpClient.login("xx", "xx"); 
     ftpClient.setFileType(FTP.BINARY_FILE_TYPE); 
     //ftpClient.setFileTransferMode(FTP.BINARY_FILE_TYPE); 
     ftpClient.enterLocalPassiveMode(); 
     boolean w = ftpClient.changeWorkingDirectory("/var/www/xx"); 


     if (ftpClient.getReplyString().contains("250")) { 
      InputStream in = null; 
      try{ 
       in = new FileInputStream(new File("xx.mp4")); 
      }catch (Exception e){ 
       e.printStackTrace(); 
       return; 
      } 

      ftpClient.sendCommand("PWD"); 


      boolean result = ftpClient.storeFile("/var/www/public_videos/xx.mp4", in); 
      System.out.println(ftpClient.getReplyString() + result); 

      in.close(); 
      ftpClient.logout(); 
      ftpClient.disconnect(); 
     } 

    } catch (SocketException e) { 
     e.printStackTrace(); 
    } catch (UnknownHostException e) { 
     e.printStackTrace(); 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 
} 

日誌:

220 ProFTPD 1.3.4a Server (Debian) [::ffff:xx.xxx.xx.xx] 
USER xx 
331 Password required for xx 
PASS xx 
230 User xx logged in 
TYPE I 
200 Type set to I 
CWD /var/www/xx 
250 CWD command successful 
PWD 
257 "/var/www/xx" is the current directory 
PASV 
227 Entering Passive Mode (xx,xx,xx,xxx,xxx,xx). 
STOR /var/www/public_videos/xx.mp4 
150 Opening BINARY mode data connection for /var/www/xx/xx.mp4 
226 Transfer complete 
226 Transfer complete 
true 
QUIT 
221 Goodbye. 

結果:

http://puu.sh/e6pVx/051c175f9e.png

+0

任何幫助的解決方案?請 :? – Totenfluch

回答

0

刪除

ftpClient.enterLocalPassiveMode(); 

導致我的問題