I'm using apache's commons-net FTPClient to upload files.
I'm using storeFileStream method.
This works well for first call but on the second call it returns null
and .getReplyStrings()
returns "200 PORT command successful" !
My Code is (that is called as a method in a loop for each file):
FileInputStream fis = null;
File LF=new File(localFilePath);
InputStream is = new FileInputStream(LF);
for(String DP:(remoteBasepath+"/"+remoteFilePath).split("/")){
if(!client.changeWorkingDirectory(DP)){
client.makeDirectory(DP);
client.changeWorkingDirectory(DP);
}
}
for(String line:client.getReplyStrings()){
System.out.println(line);
}
OutputStream os = client.storeFileStream(LF.getName());
byte[] buffer = new byte[1024];
int len;
System.out.println("start");
long RBUN=0L;
for(String line:client.getReplyStrings()){
System.out.println(line);
}
while ((len = is.read(buffer)) != -1){
os.write(buffer, 0, len);
os.flush();
RBUN+=len;
CFPRGS.setValue(Math.round((RBUN*100/LF.length())));
}
for(String line:client.getReplyStrings()){
System.out.println(line);
}
is.close();
os.close();
What is the problem?
After uploading file I should call:
client.completePendingCommand();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With