forked from Archives/langchain
Add shared Google Drive folder support (#2562)
closes #1634 Adds support for loading files from a shared Google Drive folder to `GoogleDriveLoader`. Shared drives are commonly used by businesses on their Google Workspace accounts (this is my particular use case).
This commit is contained in:
parent
7bf5b0ccd3
commit
125afb51d7
@ -148,7 +148,7 @@ class GoogleDriveLoader(BaseLoader, BaseModel):
|
||||
creds = self._load_credentials()
|
||||
service = build("drive", "v3", credentials=creds)
|
||||
|
||||
file = service.files().get(fileId=id).execute()
|
||||
file = service.files().get(fileId=id, supportsAllDrives=True).execute()
|
||||
request = service.files().export_media(fileId=id, mimeType="text/plain")
|
||||
fh = BytesIO()
|
||||
downloader = MediaIoBaseDownload(fh, request)
|
||||
@ -182,6 +182,8 @@ class GoogleDriveLoader(BaseLoader, BaseModel):
|
||||
.list(
|
||||
q=f"'{self.folder_id}' in parents",
|
||||
pageSize=1000,
|
||||
includeItemsFromAllDrives=True,
|
||||
supportsAllDrives=True,
|
||||
fields="nextPageToken, files(id, name, mimeType)",
|
||||
)
|
||||
.execute()
|
||||
@ -217,7 +219,7 @@ class GoogleDriveLoader(BaseLoader, BaseModel):
|
||||
creds = self._load_credentials()
|
||||
service = build("drive", "v3", credentials=creds)
|
||||
|
||||
file = service.files().get(fileId=id).execute()
|
||||
file = service.files().get(fileId=id, supportsAllDrives=True).execute()
|
||||
request = service.files().get_media(fileId=id)
|
||||
fh = BytesIO()
|
||||
downloader = MediaIoBaseDownload(fh, request)
|
||||
|
Loading…
Reference in New Issue
Block a user