Hi there -
I'm attempting to upload VERY large files via FTP (300 mb to up to 5 gb or so) and I'm using the following code:
FileInputStream fis = null;
FTPClient client = new FTPClient();
try {
client.connect("ftpserver.com");
if (client.login("username", "password")) {
System.out.println("login successful");
} else {
System.out.println("cant login");
}
String filename = "very_large_video_file.mov";
try {
fis = new FileInputStream(filename);
client.storeFile(filename, fis);
client.logout();
fis.close();
System.out.println("Upload complete.");
} catch (Exception e) {
System.out.println("Error..."+e.getLocalizedMessage());
}
} catch (SocketException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
This code does work, however with very large files it appears to upload them all (I only tested with a 400 mb file and the entire file uploaded) however then my JAR just hangs. When I force quit the JAR is get a "Java Result: 2147483647". After Googling that I found that it's a heap overflow error which tells me that the file is too large. How do I go about uploading these extremely large files? I'm using Apache Commons FTPClient.
Thanks!