I am trying to upload a file to an FTP server
As I've found here How do you upload a file to an FTP server?, I have this code:
FTPClient client = new FTPClient();
FileInputStream fis = null;
try {
client.connect("IP");
client.login("user", "pwd");
client.changeWorkingDirectory("/a/b/c/");
// Create an InputStream of the file to be uploaded
String filePath = file.getPath();
fis = new FileInputStream(filePath);
String fileName = file.getName();
// Store file to server
client.storeFile(fileName, fis);
client.logout();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
}
client.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
}
When I run it, the file is created where expected, but it is empty (0 kb)
The writing process also takes quite a lot of time...
What am I doing wrong?