With the official mega sdk this project is DEPRECATED.
Java library for the mega.co.nz API, currently supporting:
- login
- downloading
- list directory & files (also if shared from others)
- get download link
- add contacts
- get space left
This work is based on the source code released by @NT2005.
Import MegaJava and json library on your project
MegaHandler mh = new MegaHandler("user@mail.com", "password");
mh.login();
mh.get_user()
ArrayList<MegaFile> mf = mh.get_files();
for(int i = 0;i<mf.size();i++)
System.out.println(mf.get(i).isDirectory() ? "[DIR]"+mf.get(i).getName() : "[File]"+mf.get(i).getName());
try {
mh.download("https://mega.co.nz/#!xVUkCKbY!Aq_5U3HiWTJMEAK7N_5ENGugZVp0bMj9C8JSjgF8zBM", "C:\\Users\\admin\\Desktop");
//download displaying progress bar and speed information
mh.download_verbose("https://mega.co.nz/#!xVUkCKbY!Aq_5U3HiWTJMEAK7N_5ENGugZVp0bMj9C8JSjgF8zBM", "C:\\Users\\admin\\Desktop");
//download in the active directory
mh.download("https://mega.co.nz/#!xVUkCKbY!Aq_5U3HiWTJMEAK7N_5ENGugZVp0bMj9C8JSjgF8zBM");
} catch (InvalidAlgorithmParameterException e) {
e.printStackTrace();
}
mh.get_url(MegaFile);
mh.add_user("friend@mail.com")
mh.get_quota();