Search code examples
javaftp-clientcorrupt

Apache FTPClient upload jar files ends up being corrupt


I seem to be uploading corrupt jar files to a remote server using Apache's FTPClient 3.0.1. I am also setting the file and file transfer type to binary.

FTPClient ftp = new FTPClient();

FileInputStream fis = new FileInputStream("filename");
ftp.setFileTransferMode(org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE);
ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
ftp.storeFile(fis);
fis.close();
ftp.logout();
ftp.disconnect();

any help would be appreciated!

Jason


Solution

  • Some things to try:

    Are you absolutely 100% positive that:

    a) storeFile() is returning true b) you aren't throwing an exception somewhere

    if you step through it in a debugger does it complete each call in your routine, and the file still winds up as partial on the ftp server?

    What part of the file isn't getting to the ftp server? Create a test file that contains bytes 0-255 repeated 5 or 10 times, then try uploading that. Then download the result and see what's getting killed.