Satheesh
Satheesh

Reputation: 656

upload files to a cloud account

i need to develop an application which will peridiocally upload files from my local machine to a cloud account(cloudme account)periodically.I tried this with Java and apache commons.but i couldnt.What technology i follow.Where can i find tutorials for this?pls help?

Upvotes: 0

Views: 471

Answers (2)

Kumar Vivek Mitra
Kumar Vivek Mitra

Reputation: 33544

1. I always prefer Apache's common libs

I am also attaching my program which i used to upload and download song to ftp server using the apache's common lib

Uploading :

public void goforIt(){


        FTPClient con = null;

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

            if (con.login("Administrator", "KUjWbk"))
            {
                con.enterLocalPassiveMode(); // important!
                con.setFileType(FTP.BINARY_FILE_TYPE);
                String data = "/sdcard/vivekm4a.m4a";

                FileInputStream in = new FileInputStream(new File(data));
                boolean result = con.storeFile("/vivekm4a.m4a", in);
                in.close();
                if (result) Log.v("upload result", "succeeded");
                con.logout();
                con.disconnect();
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }






    }

Dowloading:

public void goforIt(){
    FTPClient con = null;

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

        if (con.login("Administrator", "KUjWbk"))
        {
            con.enterLocalPassiveMode(); // important!
            con.setFileType(FTP.BINARY_FILE_TYPE);
            String data = "/sdcard/vivekm4a.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

Tobi
Tobi

Reputation: 1438

I think, you should use WebDAV because cloudme supports that way.
There are also some java libs out there

Upvotes: 0

Related Questions