Proftpd - 上传后为 0kb 文件

Proftpd - 0kb file after upload

我已经搜索了很长时间,但找不到解决方案。 我正在尝试将文件从我的计算机上传到我的 ftp 服务器。但是每次我尝试,我只创建一个 0kb 文件。

我试过了

  1. 关闭防火墙
  2. 文件夹上的 chmod -R 775
  3. 20个不同版本的客户端
  4. 被动传输模式
  5. 二进制文件类型
  6. 二进制类型传输方式
  7. 使用最新的 commons-net 库 ( 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

删除

ftpClient.enterLocalPassiveMode();

导致我的问题得到解决