Skip to content
Snippets Groups Projects
Commit a955af55 authored by BIRK Renaud's avatar BIRK Renaud
Browse files

feat: Google Drive controller to handle wrong file names

parent 1e19c6f9
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,15 @@ class GDriveController:
SERVICE_ACCOUNT_FILE = "service_account.json"
SCOPES = ["https://www.googleapis.com/auth/drive.file"]
creds = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)
creds = None
try:
creds = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)
except Exception:
try:
creds = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE + ".json", scopes=SCOPES)
except Exception:
creds = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE[:-5], scopes=SCOPES)
self.drive_service = build("drive", "v3", credentials=creds)
def post_gdrive(self, local_file_path: str, folder_id: str) -> Response:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment