FTP file corrupt after download with Apache Commons Net

前端 未结 3 1048
醉话见心
醉话见心 2021-01-14 16:42

The files downloaded by this, are nearly the same size but differ in some lines. Every answer points to binary file type. But this won\'t help. Got anybody an idea for the p

3条回答
  •  时光取名叫无心
    2021-01-14 17:19

    While my problem was related to corruption of the upload, I resolved similar issue by moving the set of file type after ftp login (I dont use transfer mode leaving it to its default value):

    resultOk &= ftpClient.login(usr, pwd);
    ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
    

    I saw in some forums that setting binary file type before invoking login method, could lead to problems in transfer. Before this change, PDF file get downloaded but show corrupted fonts and elements. Now it works. Hope it may helps someone.

提交回复
热议问题