Hossein Mobasher
Hossein Mobasher

Reputation: 4472

Apache FTPClient : 530 You aren't logged in

I'm using FTPClient of apache for getting size of specific file from my server. So, the error that I faced in android is 530 You aren't logged in. while my code is such below and I've tested it in pure Java. I don't know why this error occurred on Android but all things are okay in Java.

client.connect("my-server-ip");
client.login("username", "password");
client.setKeepAlive(true);
client.setFileType(FTP.BINARY_FILE_TYPE, FTP.BINARY_FILE_TYPE);
client.setFileTransferMode(FTP.BINARY_FILE_TYPE);

client.sendCommand("SIZE " + "file-path");

try {
    sizeStr = client.getReplyString().trim();
    this.M_fileData.M_contentLength = Long.parseLong(sizeStr.split(" ")[1]);
    System.out.println(sizeStr);
} catch (NumberFormatException e) {
    e.printStackTrace();
    client.disconnect();
}

Java pure result is : 213 1757682, while android result is 530 You aren't logged in.

Could any one explain me how to solve this ?

Thanks in advance.

Upvotes: 0

Views: 5849

Answers (2)

Ehsan Rafique
Ehsan Rafique

Reputation: 117

Whenever 530 error code return it means your username or password is incorrect. And due to login failed you cant upload file.

Upvotes: 0

Kumar Vivek Mitra
Kumar Vivek Mitra

Reputation: 33544

- First of all i want you to make sure you have given the android.permission.INTERNET permission.

Well for further reference, i am giving you the code that i used to Download music clip in my android application.

I have used the Apache's commons library

public void goforIt(){


        FTPClient con = null;

        try
        {
            con = new FTPClient();
            con.connect("50.xx.xx.xx");

            if (con.login("Adminxxxxx", "KUjWbk361wobbyl-xxxxxx"))
            {
                con.enterLocalPassiveMode(); // important!
                con.setFileType(FTP.BINARY_FILE_TYPE);
                String data = "/sdcard/vivek.m4a";

                OutputStream out = new FileOutputStream(new File(data));
                boolean result = con.retrieveFile("vivekm4a.m4a", out);
                out.close();
                if (result) Log.v("download result", "succeeded");
                con.logout();
                con.disconnect();
            }
        }
        catch (Exception e)
        {
            Log.v("download result","failed");
            e.printStackTrace();
        }



    }

Upvotes: 1

Related Questions