Update google_drive.py
Browse files- google_drive.py +5 -4
google_drive.py
CHANGED
@@ -3,6 +3,7 @@ from googleapiclient.http import MediaFileUpload
|
|
3 |
from google.oauth2 import service_account
|
4 |
import json
|
5 |
import os
|
|
|
6 |
|
7 |
def upload_to_drive(local_path, filename):
|
8 |
creds_dict = json.loads(os.environ["GOOGLE_CREDS_JSON"])
|
@@ -14,6 +15,7 @@ def upload_to_drive(local_path, filename):
|
|
14 |
"parents": ["1RQx-f1UGOAY248bCIRasenJiQCHsD4Eq"]
|
15 |
}
|
16 |
media = MediaFileUpload(local_path, mimetype="application/zip")
|
|
|
17 |
try:
|
18 |
uploaded_file = service.files().create(
|
19 |
body=file_metadata,
|
@@ -21,9 +23,8 @@ def upload_to_drive(local_path, filename):
|
|
21 |
fields="id"
|
22 |
).execute()
|
23 |
except Exception as e:
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
raise
|
28 |
|
29 |
return uploaded_file.get("id")
|
|
|
3 |
from google.oauth2 import service_account
|
4 |
import json
|
5 |
import os
|
6 |
+
import traceback
|
7 |
|
8 |
def upload_to_drive(local_path, filename):
|
9 |
creds_dict = json.loads(os.environ["GOOGLE_CREDS_JSON"])
|
|
|
15 |
"parents": ["1RQx-f1UGOAY248bCIRasenJiQCHsD4Eq"]
|
16 |
}
|
17 |
media = MediaFileUpload(local_path, mimetype="application/zip")
|
18 |
+
|
19 |
try:
|
20 |
uploaded_file = service.files().create(
|
21 |
body=file_metadata,
|
|
|
23 |
fields="id"
|
24 |
).execute()
|
25 |
except Exception as e:
|
26 |
+
print("Upload failed:")
|
27 |
+
print(traceback.format_exc()) # Or log it as needed
|
28 |
+
raise Exception(f"Upload to Google Drive failed: {e}")
|
|
|
29 |
|
30 |
return uploaded_file.get("id")
|