FTP zip upload is corrupted sometimes

后端 未结 2 653
遥遥无期
遥遥无期 2020-12-03 23:22

I wrote a code for saving few images in a file and later compressing that file and uploading to an ftp server. When I download that from server, few files are fine and few f

相关标签:
2条回答
  • 2020-12-03 23:59

    Be sure to transfer files in BINARY_FILE_TYPE. Maybe ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); returns false?

    By the way, if you transfer a zip in ASCII-mode, this will almost surely result corrupted.

    0 讨论(0)
  • 2020-12-04 00:01

    See also Is java.io.BufferedOutputStream safe to use? which shows how out.close() might hide an IOException. Solution is to do an explicit out.flush() before out.close.

    Also, whatever is retrieving the file from your FTP server, is that also using BINARY mode to retrieve?

    0 讨论(0)
提交回复
热议问题