I am using Apache Commons FTPClient to upload large files, but the transfer speed is only a fraction of transfer speed using WinSCP via FTP. How can I speed up my transfer?<
It would be better if you use ftp.setbuffersize(0); if you use 0 as your buffersize , it will take as infinite buffer size. obviously ur transaction will get speeded up... I personally experienced it.. all the best... :)
There is a known issued with Java 1.7 and Commons Net 3.2, the bug is https://issues.apache.org/jira/browse/NET-493
If running these versions I'd suggest the upgrade to Commons Net 3.3 as the first step. Apparently 3.4 fixes more performance issues too.
use the outputStream method, and transfer with a buffer.
InputStream inputStream = new FileInputStream(myFile);
OutputStream outputStream = ftpclient.storeFileStream(remoteFile);
byte[] bytesIn = new byte[4096];
int read = 0;
while((read = inputStream.read(bytesIn)) != -1) {
outputStream.write(bytesIn, 0, read);
}
inputStream.close();
outputStream.close();
Increase the buffer size:
client.setBufferSize(1024000);