Google Drive connector - txt and markdown support (#1469)

This commit is contained in:
lombax85
2024-09-08 05:28:23 +02:00
committed by GitHub
parent b43e5735d7
commit c1735fcd3a

View File

@@ -62,6 +62,8 @@ class GDriveMimeType(str, Enum):
POWERPOINT = ( POWERPOINT = (
"application/vnd.openxmlformats-officedocument.presentationml.presentation" "application/vnd.openxmlformats-officedocument.presentationml.presentation"
) )
PLAIN_TEXT = "text/plain"
MARKDOWN = "text/markdown"
GoogleDriveFileType = dict[str, Any] GoogleDriveFileType = dict[str, Any]
@@ -315,12 +317,19 @@ def extract_text(file: dict[str, str], service: discovery.Resource) -> str:
GDriveMimeType.DOC.value, GDriveMimeType.DOC.value,
GDriveMimeType.PPT.value, GDriveMimeType.PPT.value,
GDriveMimeType.SPREADSHEET.value, GDriveMimeType.SPREADSHEET.value,
GDriveMimeType.PLAIN_TEXT.value,
GDriveMimeType.MARKDOWN.value,
]: ]:
export_mime_type = "text/plain" export_mime_type = "text/plain"
if mime_type == GDriveMimeType.SPREADSHEET.value: if mime_type == GDriveMimeType.SPREADSHEET.value:
export_mime_type = "text/csv" export_mime_type = "text/csv"
elif mime_type == GDriveMimeType.PPT.value: elif mime_type == GDriveMimeType.PPT.value:
export_mime_type = "text/plain" export_mime_type = "text/plain"
elif mime_type in [
GDriveMimeType.PLAIN_TEXT.value,
GDriveMimeType.MARKDOWN.value
]:
export_mime_type = mime_type
response = ( response = (
service.files() service.files()