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 |
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");
MEGA_EMAIL
: Email used as username (lowercase)MEGA_PWD
: Corresponding passwordCMD_TTL_ENV_VAR
: Maximum time to live of a running MEGAcmd command.The most common way to setup your credentials would be using environment variables MEGA_EMAIL
and MEGA_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
There were tests that moved a file to a folder where another file with the same name was present. In Windows boths files were identified as one and when I ran a move instruction for that file name it operated over the last moved file and left the oldest one in that folder. In Linux both files are keep in the folder but identified as different ones, even if the properties where the same; when a move operation was run over such filename it operated over both.
Also when I tested this on Windows I got more detailed error code, which also gives more detailed exceptions.
I suppose these issues has to do with the libraries used for making calls to the Mega API, because in the Linux version I had more features enabled that in the Windows one, whilst the Mega Cmd and SDK version were the same. It has already been reported as an issue in the MEGAcmd project. It was afterwards solved by keeping return errors always positive to be compliant with POSIX standard. Thats why an issue was raised in this repository to provide support for this new feature.
mega-help
to check all commands.
You will be able to notice those who are used in this library and others which don’t, for practical
reasons, but that will provide you additional capabilities. Try them out.Pre-release or Beta: The project has gone through multiple rounds of active development with a goal of reaching a stable release version, but is not there yet.
Path of Development: Active (November 4th 2018)
This project is licensed under the MIT License - see the LICENSE.md file for details