Skip to content

Instantly share code, notes, and snippets.

@stefanocudini
Last active August 31, 2021 05:40
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save stefanocudini/5502087 to your computer and use it in GitHub Desktop.
Save stefanocudini/5502087 to your computer and use it in GitHub Desktop.
script uploader for multiple files, using mega.co.nz python API
#!/usr/bin/env python
#
#require: https://github.com/richardasaurus/mega.py
#
import os
import sys
from mega import Mega
mega = Mega({'verbose': True})
m = mega.login('megauseremail', 'megapass')
curDir = os.getcwd() + os.path.sep
dstDirId = None
if len(sys.argv)>1 and sys.argv[1]:
srcs = sys.argv[1:]
else:
srcs = None
print srcs
if srcs:
if len(srcs) > 1 and not os.path.isfile( srcs[-1] ):#if last param isn't a local file then it is dest remote folder
dstName = srcs.pop()
dstId = m.find( dstName )
if dstId:
dstDirId = dstId[0]
print 'Destination Folder: '+ dstName
for src in srcs:
srcFile = curDir + src
if os.path.isfile( srcFile ):
#print srcFile
#print dstDirId
uppedFile = m.upload(srcFile, dstDirId)
print uppedFile
print 'Upped File Link: ' + m.get_upload_link( uppedFile )
@RobertoVeca
Copy link

Hi!
Where can I download Mega module?

Copy link

ghost commented Aug 29, 2016

You have download Mega: sudo pip install mega.py

@mascIT-98
Copy link

can you make a simple callin example?

@enadgermani
Copy link

Hello, how do i use it? what shall i modify?

@12TROLL14
Copy link

@RobertoVeca

tu peut télécharger le module mega ici : https://pypi.org/project/mega.py/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment