commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srinivas_nandula <srini.ra...@gmail.com>
Subject FTPClient.storeFile is very slow
Date Mon, 10 Dec 2007 19:28:58 GMT

I am using commons-net FTPClient utility to transfer files, sizes upto 50MB.
When i try to transfer the file using the command prompt, the file transfers
in 5 seconds. But when i use the FTPClient Utility, it takes about 1 minute.
I set the BufferSize etc to about 8MB, but the result is the same. Can
somebody suggest how i can improve the upload performance?

The code snippet is below

boolean success = false;
		try {
			connect();
			try {
				ftp.setFileType(FTP.BINARY_FILE_TYPE);
				ftp.setRemoteVerificationEnabled(false);
				StringTokenizer st = new StringTokenizer(destination, "/");
				while (st.hasMoreElements()) {
					String dir = st.nextToken();
					ftp.makeDirectory(dir);
					ftp.changeWorkingDirectory(dir);
				}
				
				ftp.setBufferSize(100000);
				
				logger.info("Start Time For Sending Track"
						+ fileName
						+ " "
						+ DateFormatUtils.format(Calendar.getInstance().getTime(),
								"yyyy-MM-dd hh:mm:ss"));
				
				File f = new File(source + File.separator + fileName);
				FileInputStream fis = new FileInputStream(f);
				success = ftp.storeFile(fileName, fis);
				fis.close();
				
				logger.info("End Time For Sending Track"
						+ fileName
						+ " "
						+ DateFormatUtils.format(Calendar.getInstance().getTime(),
								"yyyy-MM-dd hh:mm:ss")); 
			} catch (Exception e) {
				if(e.getMessage().startsWith("Host attempting data connection")){
					success = true;
				}
				logger.severe(e);
				try {
					ftp.disconnect();
				} catch (IOException e2) {
					// TODO Auto-generated catch block
					logger.severe(e2);
				}
			}
		} catch (Exception e) {
			success = false;
		}
-- 
View this message in context: http://www.nabble.com/FTPClient.storeFile-is-very-slow-tp14259748p14259748.html
Sent from the Commons - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message