I have a program in Java that uses ftp4j library to upload pictures to FTP server. Sometimes the images are fine but sometimes the bottom half of them is either black or don't exist at all (kinda like cut). What could be the reason to it and how to fix it? The mode for uploading is set on binary.
The code
try{
client.connect(serverName);
client.login(serverUser, serverPass);
System.out.println("Connection with the server created");
if(serverHome == null){
serverHome = "";
}
client.changeDirectory(serverHome+"/screenshotuploader/users/"+user);
int count = new IOCounter().FileReader("count.txt");
client.setType(FTPClient.TYPE_BINARY);
client.upload(new java.io.File("screenshots/screen"+(count-1)+".png"));
System.out.println("Screenshot nr "+(count-1)+" has been uploaded");
SystemTray notif = new SystemTray();
notif.Bubble(0);
Clipboard.setClipboard(new IOCounter().FTPtoHTTP(serverName)+
"/screenshotuploader/users/"+user+"/screen"+(count-1)+".png");
//Shows entire file list in the folder
String dir = client.currentDirectory();
FTPFile[] list = client.list();
for (int i=0; i < list.length; i++){
System.out.println(list[i]);
}
client.disconnect(true);
}
catch (IllegalStateException | IOException | FTPIllegalReplyException |
FTPException | FTPDataTransferException | FTPAbortedException |
FTPListParseException e){
e.printStackTrace();
System.out.println("Something went wrong with uploading the image");
SystemTray notif = new SystemTray();
notif.Bubble(1);
}
I have not tried active passive mode as I am behind a router and I thought I can't make active connection like that.