Unable to upload large files on FTP using Apache commons-net-3.1

Posted by Nitin on Stack Overflow See other posts from Stack Overflow or by Nitin
Published on 2012-03-22T10:54:44Z Indexed on 2012/03/22 11:29 UTC
Read the original article Hit count: 368

Filed under:
|
|

I am trying to upload the one large file ( more than 8 MB) using storeFile(remote, local) method of FTPClient but it results false.It get uploaded with some extra bytes.Following is the code with Output:

public class Main {
public static void main(String[] args) {
FTPClient client = new FTPClient();
FileInputStream fis = null;

try {

client.connect("208.106.181.143");
client.setFileTransferMode(client.BINARY_FILE_TYPE);
client.login("abc", "java");
int reply = client.getReplyCode();
System.out.println("Received Reply from FTP Connection:" + reply);

if(FTPReply.isPositiveCompletion(reply)){
    System.out.println("Connected Success");
}

client.changeWorkingDirectory("/"+"Everbest"+"/");
client.makeDirectory("ETPSupplyChain5.3-EvbstSP3");
client.changeWorkingDirectory("/"+"Everbest"+"/"+"ETPSupplyChain5.3-EvbstSP3"+"/");
FTPFile[] names = client.listFiles();
 String filename = "E:\\Nitin\\D-Drive\\Installer.rar";

fis = new FileInputStream(filename);

boolean result = client.storeFile("Installer.rar", fis);
 int replyAfterupload = client.getReplyCode();
System.out.println("Received Reply from FTP Connection replyAfterupload:" + replyAfterupload);
System.out.println("result:"+result);
for (FTPFile name : names) {
    System.out.println("Name = " + name);
  }

client.logout();

fis.close();



client.disconnect();
} catch (SocketException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
 }
}




o/p:
Received Reply from FTP Connection:230
Connected Success
32   /Everbest/ETPSupplyChain5.3-EvbstSP3
Received Reply from FTP Connection replyAfterupload:150
result:false

© Stack Overflow or respective owner

Related posts about java

Related posts about ftp-client