drive convert to pdf and include file extension

This commit is contained in:
phact 2025-09-08 23:58:26 -04:00
parent 1d5d26b456
commit 2fbc852eb3
2 changed files with 7 additions and 4 deletions

View file

@ -400,8 +400,9 @@ class GoogleDriveConnector(BaseConnector):
export_mime = self._pick_export_mime(mime_type) export_mime = self._pick_export_mime(mime_type)
if mime_type.startswith("application/vnd.google-apps."): if mime_type.startswith("application/vnd.google-apps."):
# default fallback if not overridden # default fallback if not overridden
if not export_mime: #if not export_mime:
export_mime = "application/pdf" # export_mime = "application/pdf"
export_mime = "application/pdf"
# NOTE: export_media does not accept supportsAllDrives/includeItemsFromAllDrives # NOTE: export_media does not accept supportsAllDrives/includeItemsFromAllDrives
request = self.service.files().export_media(fileId=file_id, mimeType=export_mime) request = self.service.files().export_media(fileId=file_id, mimeType=export_mime)
else: else:

View file

@ -53,9 +53,11 @@ class LangflowConnectorService:
filename=document.filename, filename=document.filename,
) )
suffix = self._get_file_extension(document.mimetype)
# Create temporary file from document content # Create temporary file from document content
with tempfile.NamedTemporaryFile( with tempfile.NamedTemporaryFile(
delete=False, suffix=self._get_file_extension(document.mimetype) delete=False, suffix=suffix
) as tmp_file: ) as tmp_file:
tmp_file.write(document.content) tmp_file.write(document.content)
tmp_file.flush() tmp_file.flush()
@ -65,7 +67,7 @@ class LangflowConnectorService:
logger.debug("Uploading file to Langflow", filename=document.filename) logger.debug("Uploading file to Langflow", filename=document.filename)
content = document.content content = document.content
file_tuple = ( file_tuple = (
document.filename, document.filename+suffix,
content, content,
document.mimetype or "application/octet-stream", document.mimetype or "application/octet-stream",
) )