Spaces:
Sleeping
Sleeping
Anna Zhou commited on
Commit ·
3a9eebe
1
Parent(s): c8016f6
Clarify Drive intake upload errors
Browse files- app/app.py +10 -1
- app/drive_request_uploader.py +11 -2
app/app.py
CHANGED
|
@@ -660,7 +660,16 @@ def _render_new_case_requests_page() -> None:
|
|
| 660 |
"The request could not be saved to Google Drive. Please try again later "
|
| 661 |
"or contact the RFR team."
|
| 662 |
)
|
| 663 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 664 |
return
|
| 665 |
|
| 666 |
st.success("Request submitted. The RFR team can now review it in the Google Drive intake folder.")
|
|
|
|
| 660 |
"The request could not be saved to Google Drive. Please try again later "
|
| 661 |
"or contact the RFR team."
|
| 662 |
)
|
| 663 |
+
error_text = str(exc)
|
| 664 |
+
if "Service Accounts do not have storage quota" in error_text:
|
| 665 |
+
st.caption(
|
| 666 |
+
"Drive upload error: Google service accounts cannot own new files in a regular "
|
| 667 |
+
"My Drive folder. Move the intake folder to a Google Shared Drive, give the "
|
| 668 |
+
"service account Content manager or Manager access, and update "
|
| 669 |
+
"RFR_REQUESTS_DRIVE_FOLDER_ID to that Shared Drive folder ID."
|
| 670 |
+
)
|
| 671 |
+
else:
|
| 672 |
+
st.caption(f"Drive upload error: {exc}")
|
| 673 |
return
|
| 674 |
|
| 675 |
st.success("Request submitted. The RFR team can now review it in the Google Drive intake folder.")
|
app/drive_request_uploader.py
CHANGED
|
@@ -43,7 +43,11 @@ def _create_folder(service, parent_folder_id: str, name: str) -> dict:
|
|
| 43 |
"mimeType": "application/vnd.google-apps.folder",
|
| 44 |
"parents": [parent_folder_id],
|
| 45 |
}
|
| 46 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
def _upload_bytes(
|
|
@@ -60,7 +64,12 @@ def _upload_bytes(
|
|
| 60 |
metadata = {"name": filename, "parents": [parent_folder_id]}
|
| 61 |
return (
|
| 62 |
service.files()
|
| 63 |
-
.create(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
.execute()
|
| 65 |
)
|
| 66 |
|
|
|
|
| 43 |
"mimeType": "application/vnd.google-apps.folder",
|
| 44 |
"parents": [parent_folder_id],
|
| 45 |
}
|
| 46 |
+
return (
|
| 47 |
+
service.files()
|
| 48 |
+
.create(body=metadata, fields="id,name,webViewLink", supportsAllDrives=True)
|
| 49 |
+
.execute()
|
| 50 |
+
)
|
| 51 |
|
| 52 |
|
| 53 |
def _upload_bytes(
|
|
|
|
| 64 |
metadata = {"name": filename, "parents": [parent_folder_id]}
|
| 65 |
return (
|
| 66 |
service.files()
|
| 67 |
+
.create(
|
| 68 |
+
body=metadata,
|
| 69 |
+
media_body=media,
|
| 70 |
+
fields="id,name,webViewLink",
|
| 71 |
+
supportsAllDrives=True,
|
| 72 |
+
)
|
| 73 |
.execute()
|
| 74 |
)
|
| 75 |
|