• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..18-Sep-2020-

README.mdH A D18-Sep-20202.1 KiB6646

crud_example.pyH A D18-Sep-202011.2 KiB338237

megacli.pyH A D18-Sep-202013.1 KiB463346

README.md

1# Example app using Python
2
3There are two basic examples contained here. A Mega Command Line Interface
4client (`megacli`), and a simple CRUD example (create, read, update, delete
5a file).
6
7To build the required (Python) modules, see the `README.md` in
8`bindings/python/`.
9
10## Mega Command Line Interface
11
12This is a console app that uses the Python bindings of the SDK.
13
14It shows a shell like the one in the `megacli` example that allows to:
15
16- Log in to a MEGA account (`login`, `logout`)
17- Browse folders (`cd`, `ls`, `pwd`)
18- Create new folders (`mkdir`)
19- Show the inbound shared folders (`mount`)
20- Upload/download files (`put`, `get`)
21- Delete, rename and move files/folders (`rm`, `mv`)
22- Import files and export files/folders (`import`, `export`)
23- Change the password of the account (`passwd`)
24- Get info about the account (`whoami`)
25
26Prerequisite:
27
28- Installed Mega SDK with Python bindings and the Python module `cmd` (or `cmd2`).
29
30To start the client just run `megacli.py` from this folder.
31
32
33## Mega CRUD Example
34
35Just run `crud_example.py` from this folder.
36
37To avoid typing in credentials, you may create a `credentials.json` file with
38the following content:
39
40```
41{
42    "user": "your.email@provider.org",
43    "password": "your_supersecret_password"
44}
45```
46
47
48## To Keep In Mind
49
50If you want to create your own Python app, you can use the `MegaApi`
51object. However, these bindings are still a work in progress and have
52some inconveniences:
53
54- You can't use callback parameters out of the callbacks. Instead, you can use
55  the `copy()` method of `MegaRequest`, `MegaTransfer` and `MegaError`
56  to preserve them and to use them later.
57- You can't use objects returned by `MegaNodeList`,
58  `MegaTransferList`, `MegaShareList` or `MegaUserList` after losing
59  the reference to the original list. You can use the `copy()` method
60  commented above to preserve those objects.
61- You must keep a reference in your app to listeners used to receive
62  events, otherwise the SDK will crash when it tries to use them.
63
64We plan to create a `MegaApiPython` wrapper on top of `MegaApi` to
65take care of these issues for you.
66