Since you didnt get any error try followed example that worked for me.
Before,
- check that FTP is enable for your server.
- be sure that device has the same sub net with Server
- (optimal) on running FTP upload, check on server side
access_log
/error_log
withtail
. Verify that server listens and gets something
I use commons-net-3.1.jar
Here is the method where we upload bin file:
public void uploadFileToServer(
String serverIP,
String binFileToStore,
String workingRemoteFolder,
String localFilePath,
String timeout
){
Log.d("test", "init FTP client ...");
// set FTP client
FTPClient client = new FTPClient();
client.setConnectTimeout(Integer.parseInt(timeout)*1000);
client.setDefaultTimeout(Integer.parseInt(timeout)*1000);
client.setControlKeepAliveTimeout(Long.parseLong(timeout) );
try{
int reply;
Log.d("test", "connecting ...");
client.connect(serverIP);
// After connection attempt, you should check the reply code to verify
// success.
reply = client.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply))
{
client.disconnect();
//error
return;
}
}
catch (IOException e){
return;
}
/** set setup configuration. We upload bin file */
FileInputStream fis = null;
try{
client.setFileType(FTP.BINARY_FILE_TYPE, FTP.BINARY_FILE_TYPE);
client.setFileTransferMode(FTP.BINARY_FILE_TYPE);
client.enterLocalPassiveMode();
client.login("automation", "automation");
//
// Create an InputStream of the file to be uploaded
//
fis = new FileInputStream(localFilePath);
if (!client.changeWorkingDirectory(workingRemoteFolder)){
client.makeDirectory(workingRemoteFolder);
client.changeWorkingDirectory(workingRemoteFolder);
}
Log.d("test", "store file ...");
boolean result = client.storeFile(binFileToStore, fis);
// done
client.logout();
} catch (IOException e) {
} finally {
try {
if (fis != null) {
fis.close();
}
client.disconnect();
} catch (IOException e) {
return;
}
}
}
Hope this example will help you