route1io_connectors.google.drive module

Google Drive connectors

This module contains functions for interacting with Google Drive

References

Upload file data

https://developers.google.com/drive/api/v3/manage-uploads

Create and populate folders

https://developers.google.com/drive/api/v3/folder

Files: create

https://developers.google.com/drive/api/v3/reference/files/create

connect_to_google_drive(credentials: google.oauth2.credentials.Credentials) googleapiclient.discovery.Resource

Return a connection to Google Drive

Parameters

credentials (google.oath2.credentials.Credentials) – Valid Credentials object with necessary authentication

Returns

google_drive_conn – Connection to Google Drive API

Return type

googleapiclient.discovery.Resource

upload_file(drive: googleapiclient.discovery.Resource, fpath: str, name: str = None, folder_id: str = None) Dict[str, str]

POST request a file to a Google Drive folder and return the response

Parameters
  • drive ("googleapiclient.discovery.Resource") – Authenticated connection to Google Drive API

  • fpath (str) – Filepath of the file we want to upload to Drive

  • name (str) – Name of the file as it will appear in Drive

  • folder_id (str) – ID of the folder to upload to

Returns

response – Response from Google after POST requesting file

Return type

Dict[str, str]