Hi.
I'm using <a href=" FTPClient</a> for uploading video and picture to server, but I'm experiencing some major upload speed trouble. The upload goes so slow that it seems like my application freezes and eventually my application gets pinged out.
My code is:
<code>
public boolean uploadVideo(String localVideoPath)
throws FTPClientException{
try{
ftp.connect(filmServer);
result = ftp.getReplyString();
if(!(result.substring(0,3).equals("220") ) )
throw new FTPClientException("Kunne ikke koble til server");
ftp.setFileType(FTP.BINARY_FILE_TYPE);
ftp.enterLocalPassiveMode();
ftp.login( filmServerUser, filmServerPass );
ftp.setBufferSize(100000);
result = ftp.getReplyString();
if(!(result.substring(0,3).equals("230") ) )
throw new FTPClientException("Feil brukernavn / passord");
InputStream localFileStream = new FileInputStream(localVideoPath);
char illegalChar = '\\';
String tmpName = localVideoPath.replace(illegalChar, '/');
String remoteFileName = tmpName.substring(
localVideoPath.lastIndexOf("/")+1 );
System.out.println(File.pathSeparatorChar);
ftp.setFileType(FTP.BINARY_FILE_TYPE);
ftp.storeFile(remoteFileName, localFileStream);
result = ftp.getReplyString();
if(!(result.substring(0,3).equals("226") ) )
throw new FTPClientException("Opplasting misslykket");
System.out.println( ftp.getReplyString() );
ftp.logout();
ftp.disconnect();
System.out.println( ftp.getReplyString() );
}catches all lot of exceptions {}
return true;
}
</code>
Why is the connectionspeed so slow?
I'm using <a href=" FTPClient</a> for uploading video and picture to server, but I'm experiencing some major upload speed trouble. The upload goes so slow that it seems like my application freezes and eventually my application gets pinged out.
My code is:
<code>
public boolean uploadVideo(String localVideoPath)
throws FTPClientException{
try{
ftp.connect(filmServer);
result = ftp.getReplyString();
if(!(result.substring(0,3).equals("220") ) )
throw new FTPClientException("Kunne ikke koble til server");
ftp.setFileType(FTP.BINARY_FILE_TYPE);
ftp.enterLocalPassiveMode();
ftp.login( filmServerUser, filmServerPass );
ftp.setBufferSize(100000);
result = ftp.getReplyString();
if(!(result.substring(0,3).equals("230") ) )
throw new FTPClientException("Feil brukernavn / passord");
InputStream localFileStream = new FileInputStream(localVideoPath);
char illegalChar = '\\';
String tmpName = localVideoPath.replace(illegalChar, '/');
String remoteFileName = tmpName.substring(
localVideoPath.lastIndexOf("/")+1 );
System.out.println(File.pathSeparatorChar);
ftp.setFileType(FTP.BINARY_FILE_TYPE);
ftp.storeFile(remoteFileName, localFileStream);
result = ftp.getReplyString();
if(!(result.substring(0,3).equals("226") ) )
throw new FTPClientException("Opplasting misslykket");
System.out.println( ftp.getReplyString() );
ftp.logout();
ftp.disconnect();
System.out.println( ftp.getReplyString() );
}catches all lot of exceptions {}
return true;
}
</code>
Why is the connectionspeed so slow?