mega.py
mega.py copied to clipboard
Could not a create folder on mega.py API
This is the error i'm getting.
I try to reinstall mega,py but still the error is persistent.
I don't know the heavy details here, but this error is thrown when file[1]['a'] is of string type instead of a dictionary. The following change to the find_path_descriptor method (see commented line below) appears to fix the issue.
def find_path_descriptor(self, path, files=()):
"""
Find descriptor of folder inside a path. i.e.: folder1/folder2/folder3
Params:
path, string like folder1/folder2/folder3
Return:
Descriptor (str) of folder3 if exists, None otherwise
"""
paths = path.split('/')
files = files or self.get_files()
parent_desc = self.root_id
found = False
for foldername in paths:
if foldername != '':
for file in files.items():
# if (file[1]['a'] and file[1]['t']
if (isinstance(file[1]['a'], dict) and file[1]['t']
and file[1]['a']['n'] == foldername):
if parent_desc == file[1]['p']:
parent_desc = file[0]
found = True
if found:
found = False
else:
return None
return parent_desc