cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeremy Weatherford" <jer...@neteamavi.com>
Subject FTPClient and incomplete downloads?
Date Mon, 06 Nov 2006 18:28:31 GMT
Hello,

I just discovered that FTPClient is having problems with larger files being
retrieved incompletely.  An example file retrieved via FileZilla and
FTPClient (both in binary mode) had:

FileZilla size:	282,843,303 bytes
FTPClient size:	282,838,183 bytes

Obviously this causes a problem.  The relevant code is:

        FTPClient cli = new FTPClient();

        try {
            cli.connect(enc.ip);
            int reply = cli.getReplyCode();
            if (!FTPReply.isPositiveCompletion(reply)) {
                cli.disconnect();
                error("Connection refused."); return;
            }
            if (!cli.login("user", "pass") {
                error("Bad user/password"); return;
            }
            cli.setFileType(FTP.BINARY_FILE_TYPE);
            
            try {
                FTPFile[] files = cli.listFiles(filename);
                sizekbytes = files[0].getSize() / 1024;
                System.out.println(filename + " is " + sizekbytes + " KB");
            } catch (Exception e) {}
            
            status = "Transferring...";
            os = new FileOutputStream(destination + "\\" + filename);
            if (!cli.retrieveFile(filename, os)) {
                error("Could not retrieve file."); return;
            }
            
            os.close();
        } catch (Exception e) {
            if (cli.isConnected()) try { cli.disconnect(); } catch
(Exception e2) {}
            error("FTP exception: " + e.getMessage());
        }

The only other strange thing I'm doing is periodically interrogating the
OutputStream's position from another thread for progress reporting: 

	long pos = os.getChannel().position() / 1024;

The banner at the server is "220 Microsoft FTP Service", and the OS is
Windows 2003.  Client OS is Windows XP.

Any ideas?  I really like some of the features offered by this library, but
this is a huge problem.

Thanks,
Jeremy


Mime
View raw message