official mega sdk this project is DEPRECATED.
With theMegaJava
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.
Requirements
How to use
Import MegaJava and json library on your project
Login (you need this step before do anything)
MegaHandler mh = new MegaHandler("user@mail.com", "password");
mh.login();
Get user details
mh.get_user()
Get and print user files
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());
Download files from url
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();
}
Get download url (works only against own files)
mh.get_url(MegaFile);
Add a contact
mh.add_user("friend@mail.com")
Get free space (bytes)
mh.get_quota();