Browse Source

yyfvbetbfwafbtwbwttbhqr

partialg
event_class
Raphael Roberts 7 years ago
parent
commit
f752a5455d
  1. 16
      gapi/drive_api.py

16
gapi/drive_api.py

@ -71,14 +71,28 @@ class drive_api(API):
def __upload_file__(self,local_path,remote_path):
'''creates file if it does not exists otherwise update the file'''
isdir = os.path.isdir(local_path)
mimetype = from_file(local_path,mime_type=True)
_upload = MeduaFileUpload(local_path,mimeType=mimetype)
try:
fid = get_file_by_path(remote_path)
self.service.files().update(fileId=fid,mediaBody=_upload)
except FileNotFoundError:
path = split_path(remote_path)
end = path.pop()
parent = mkdirs(path)
parent_id = parent[0]['id']
meta = {
'name':end,
'parents':[parent_id]
}
new_f_meta = self.service.files().create(
body = meta,
mediaBody = _upload
).execute()
parent['files']['end'] = new_f_meta
def mkdirs(self,path):

Loading…
Cancel
Save