Commit 25da169b authored by Tiago Peixoto's avatar Tiago Peixoto

Fix save_gdrive_file()

parent 384cf457
......@@ -33,14 +33,17 @@ else:
with open('gdrive_token.pickle', 'wb') as f:
pickle.dump(creds, f)
drive_service = None
gdrive_service = None
def save_gdrive_file(file_id, fobj):
def save_gdrive_file(file_id, fobj, check_health=False):
global gdrive_service, creds
if gdrive_service is None:
drive_service = build('drive', 'v3', credentials=creds)
request = drive_service.files().get_media(fileId=file_id)
downloader = MediaIoBaseDownload(fobj, request)
gdrive_service = build('drive', 'v3', credentials=creds)
request = gdrive_service.files().get_media(fileId=file_id)
downloader = MediaIoBaseDownload(fobj, request,
chunksize=104857600 if not check_health else 1)
done = False
while not done:
status, done = downloader.next_chunk()
if check_health:
return
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment