I'm using org.apache.commons.net.ftp.FTPSClient
for sending files to another server. But the program hangs after
boolean stored = client.storeFile(fileName, is);
The file is sent but on the server it has zero bytes.
I tried sending the same file to the same server using Filezilla
and it gets transferred with no problems, so I don't think this is a firewall issue.
I also made sure that my InputStream
is reading the file by printing its contents.
Here's my code:
FTPSClient client = new FTPSClient();
InputStream is = null;
client.connect(AppValues.ftpurl);
client.login(AppValues.ftpname, AppValues.ftppass);
is = new FileInputStream("C:\\Users\\path\\filename");
boolean stored = client.storeFile(fileName, is);
System.out.println("Stored? " + stored);
The Stored printout is never called, and the file arrives with zero bytes.
What am I missing?
FTPClient client = = new FTPClient();
InputStream is = null;
client.connect(AppValues.ftpurl);
client.login(AppValues.ftpname, AppValues.ftppass);
client.setFileType(FTP.BINARY_FILE_TYPE);
client.enterLocalPassiveMode();
is = new FileInputStream("C:\\Users\\path\\filename");
boolean stored = client.storeFile(fileName, is);
System.out.println("Stored? " + stored);