diff --git a/gapi/drive_api.py b/gapi/drive_api.py index 6c82564..08b2d7c 100644 --- a/gapi/drive_api.py +++ b/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):