megapy/tests.py

49 lines
962 B
Python
Raw Normal View History

2013-02-04 02:02:33 +00:00
from mega import Mega
def test():
#user details
2013-02-08 12:23:28 +00:00
email = 'your@email.com'
password = 'password'
2013-02-04 02:02:33 +00:00
mega = Mega()
#login
m = mega.login(email, password)
2013-02-04 02:02:33 +00:00
#get user details
2013-02-04 04:42:28 +00:00
details = m.get_user()
print(details)
#get account files
2013-02-04 02:02:33 +00:00
files = m.get_files()
#example iterate over files
for file in files:
2013-02-23 15:08:36 +00:00
print(files[file])
2013-02-04 02:02:33 +00:00
#upload file
print(m.upload('tests.py'))
2013-02-04 02:02:33 +00:00
#search for a file in account
file = m.find('tests.py')
if file:
#get public link
link = m.get_link(file)
print(link)
#download file. by file object or url
m.download(file, '/tmp')
#m.download_url(link)
#delete or destroy file. by id or url
print(m.delete(file[0]))
#print(m.destroy(file[0]))
#print(m.delete_url(link))
#print(m.destroy_url(link))
#empty trash
print(m.empty_trash())
2013-02-04 02:02:33 +00:00
if __name__ == '__main__':
test()