This is an open source Java library for the mega.nz API, working on top of the MEGAcmd CLI. There is a Quick Start available for developers who want to start using the library right away.
Feature | MEGAcmd | Description |
---|---|---|
Start session | login |
Allows to authenticate into the mega api to start running commands using user and password, or sessionID or an exported/public folder |
Close session | logout |
Close the current session. |
Put content in the Cloud | put |
Upload content to the cloud. |
Session Id | session |
Returns the id of the current session. |
HTTPS | https |
Shows if HTTPS is used for transfers. Allows enabling and disabling this option. |
Idenfity current username | whoami |
Returns the username of the current session. |
Make directory | mkdir |
Creates a directory or multiple based on a given remote path. |
List files/directories | ls |
List files and directories in a remote path. |
Get content | get |
Get the content of files and directories in a remote path. |
Copy | cp |
Copy remote files and directories into a new location. |
Move | mv |
Move remote files and directories into a new location. |
Change password | passwd |
Changes the password of the currently logged user. |
Shares folder | share |
Shares/Unshares folder with user |
Export to the Internet | export |
Create, delete or list existing public links |
Signup user | signup |
Register as user with a given email |
Version | version |
Prints MEGAcmd versioning and extra info |
Quit | quit |
Quits MEGAcmd. Stops the server without killing the session |
Import | import |
Imports the contents of a remote link into user's cloud |
If you have any doubt about how each feature works, please run
MegaClient <MEGAcmd> --help
This features have no corresponding Megacmd command, but they are infered from the existing ones
Show the amount of elements in a folder or that match the query mask. E.g.
final long amountOfFilesAndDirectories = sessionMega.count("remote/path");
But what if you want to filter that counting and it a Predicate to, for instance, just get the files and not the directories.
final long amountOfFiles = sessionMega.count("remote/path", FileInfo::isFile);
This is pretty much the equivalent of java.io.File.exists
. It checks if the remote path or mask
indicates any non null response. E.g.
sessionMega.exists("remote/path/filesprefix*.ext");
With a premium mega account, you can export and generate public folder links by setting the option expire date
.
LocalDate expireDate = LocalDate.of(2020, 9, 2);
final ExportInfo exportInfo = sessionMega.export(exportFolder)
.setExpireDate(expireDate)
.call();
or you can just specify a duration using TimeDelay
.
final ExportInfo exportInfo = sessionMega.export(exportFolder)
.setExpirationTimeDelay(TimeDelay.of(
Period.ofYears(3).plusMonths(11).plusDays(15)
))
.call();
Thanks to the class io.github.eliux.mega.MegaServer
you can now start
and stop
the local MEGAcmdServer on command.
MEGA_EMAIL
: Email used as username (lowercase)MEGA_PWD
: Corresponding passwordCMD_TTL_ENV_VAR
: Maximum time to live of a running MEGAcmd command. By default, 20 seconds.
-
The most common way to setup your credentials would be using the environment variables
MEGA_EMAIL
andMEGA_PWD
. -
Use an existing session can be a saver way. You can use it from your app as long as it don't be closed.
As most OSS projects in github, this one uses Travis CI. I you want a CLI for your project, its recommend to install the correspondent ruby gem:
gem install travis
- Once installed MEGAcmd in your system, execute
mega-help
to check all commands. You will be able to notice those who are already implemented in this library and those who don't. Try them out.
Make sure your contact data is included in the Contributors section, and
- Follow the Google Java Style Guide as much as possible: Its recommended that you install the Google Java Style Guide settings in your IDE.
- Respect as much as possible the format of the provided templates for issues and PRs.
Add your name, email and your account for Twitter, Github or LinkedIn:
- Cenyo Medewou - [email protected] | Github | Linkedin
- Java SDK 8 - Java™ Platform
- Maven - Dependency Management
- MEGAcmd - Command Line Interactive and Scriptable Application
- Eliecer Hernandez - [email protected]. For more information, please visit my website.
This project is licensed under the MIT License - see the LICENSE.md file for details