This repository was archived by the owner on Jul 22, 2021. It is now read-only.

Description
Google api Client don't give me latest version of file stored on google drive. It will always give me older version of file
Any help in this will be helpful
Thanks in Advance
def get_drive_service(self):
if not self.env.user.oauth_access_token:
raise UserError(_("Please Add google access token to your account for uploading files to google drive"))
cred = Credentials(self.env.user.oauth_access_token)
service = build("drive", "v3", credentials=cred)
return service
def convert_to_doc(self):
if not self.google_drive_link:
raise ValidationError(_("Please Add url of file"))
file_id = self._get_key_from_url(self.google_drive_link)
service = self.get_drive_service()
with google_service_context() as manager:
file = service.files().get(fileId=file_id).execute()
request = service.files().get_media(fileId=file_id)
fh = io.BytesIO()
with google_service_context() as manager:
downloader = MediaIoBaseDownload(fh, request)
done = False
while done is False:
with google_service_context() as manager:
status, done = downloader.next_chunk()
fh.seek(0)
self.write(
{'doc_type': 'upload_attachment', 'content_binary': base64.b64encode(fh.read()), 'name': file.get('name')})
return self