Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Jakarta FTPClient: Upload speed trouble

Status
Not open for further replies.

azidops

Programmer
May 19, 2005
2
NO
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?
 
To post code using TGML, use square brackets for the tags.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Maybe this is better:

I'm using [a href="[URL unfurl="true"]http://jakarta.apache.org/commons/net/apidocs/org/apache/commons/net/ftp/FTPClient.html#method_summary"[/URL]]Jakarta's 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;
    }
Why is the connectionspeed so slow?
 
Are you sure it has to do with the program and not the connection itself?

Cheers,

Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top