You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by srinivas_nandula <sr...@gmail.com> on 2007/12/10 20:28:58 UTC

FTPClient.storeFile is very slow

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


Re: FTPClient.storeFile is very slow

Posted by Thorbjørn Ravn Andersen <th...@gmail.com>.
srinivas_nandula skrev  den 10-12-2007 20:28:
> 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?
>   
Could you add logging to see exactly where the time is spent?

-- 
  Thorbjørn

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