0

I have edited the following code after marked as duplicate where I placed the code in a background task as a suggested fix for NetworkOnMainThreadException.

The code is meant to upload a .zip file to my FTP server hosted on my computer. Error appears to occur when attempting to connect to the server, however I could not figure out a solution. I am quite new to this so sorry if this is a bad post :) . Thank you.

update: I fixed the problem and was due to the welcome message sent from the filezilla ftp server to turn up as unrecognized, to fix it I changed the message to "hello world" as I thought the '-' in the initial message was causing the issue.

private class uploadDatabase extends AsyncTask<String,String,String> {
    @Override
    protected String doInBackground(String...arg0){
        String host = arg0[0];
        String user = arg0[1];
        String pass = arg0[2];
        zipFileAtPath("/mnt/sdcard/some_file/Database","/mnt/sdcard/some_file/Databases.zip");
        try{
            SimpleFTP ftp = new SimpleFTP();
            ftp.connect(host,21,user,pass);
            ftp.bin();
            ftp.cwd("web");
            ftp.stor(new File("/mnt/sdcard/some_file/Databases.zip"));
            ftp.disconnect();
        }catch(IOException e) {
            System.out.println("Upload error");
        }
        return null;

    }
}

Log:

03-18 18:31:26.881 13575-13604/com.hr.hrproductions.bemathly I/System.out: Upload error: SimpleFTP received an unknown response when connecting to the FTP server: 220-FileZilla Server 0.9.56 beta
03-18 18:31:27.759 13575-13575/com.hr.hrproductions.bemathly D/AppTracker: App Event: stop
03-18 18:31:27.803 13575-13575/com.hr.hrproductions.bemathly D/AppTracker: App Event: start
03-18 18:31:27.835 13575-13575/com.hr.hrproductions.bemathly D/AbstractTracker: Event success
03-18 18:31:27.844 13575-13575/com.hr.hrproductions.bemathly D/AbstractTracker: Event success
03-18 18:31:27.981 13575-13575/com.hr.hrproductions.bemathly I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@2d07adda time:272984263
03-18 18:33:29.578 13575-13575/com.hr.hrproductions.bemathly D/AppTracker: App Event: stop
03-18 18:33:29.661 13575-13575/com.hr.hrproductions.bemathly D/AbstractTracker: Event success    

0 Answers0