mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-14 17:03:29 +03:00
fix: 🐛 upload (#2112)
now you can download & view pdf # Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
This commit is contained in:
parent
f83c58de7f
commit
37b9901fe8
@ -28,6 +28,10 @@ class Notifications(NotificationInterface):
|
||||
notification_id,
|
||||
notification,
|
||||
):
|
||||
if notification_id is None:
|
||||
logger.info("Notification id is required")
|
||||
return None
|
||||
|
||||
"""Update a notification by id"""
|
||||
response = (
|
||||
self.db.from_("notifications")
|
||||
|
@ -44,5 +44,7 @@ class NotificationService:
|
||||
"""
|
||||
Update a notification
|
||||
"""
|
||||
|
||||
return self.repository.update_notification_by_id(notification_id, notification)
|
||||
if notification:
|
||||
return self.repository.update_notification_by_id(
|
||||
notification_id, notification
|
||||
)
|
||||
|
@ -85,7 +85,7 @@ async def upload_file(
|
||||
"name": uploadFile.filename if uploadFile else "Last Upload File",
|
||||
}
|
||||
notification_service.update_notification_by_id(
|
||||
upload_notification.id,
|
||||
upload_notification.id if upload_notification else None,
|
||||
NotificationUpdatableProperties(
|
||||
status=NotificationsStatusEnum.Done,
|
||||
message=str(notification_message),
|
||||
|
@ -1,4 +1,5 @@
|
||||
import json
|
||||
import os
|
||||
from multiprocessing import get_logger
|
||||
|
||||
from langchain.pydantic_v1 import Field
|
||||
@ -8,14 +9,48 @@ from supabase.client import Client
|
||||
|
||||
logger = get_logger()
|
||||
|
||||
# Mapping of file extensions to MIME types
|
||||
mime_types = {
|
||||
".txt": "text/plain",
|
||||
".csv": "text/csv",
|
||||
".md": "text/markdown",
|
||||
".markdown": "text/markdown",
|
||||
".telegram": "application/x-telegram",
|
||||
".m4a": "audio/mp4",
|
||||
".mp3": "audio/mpeg",
|
||||
".webm": "audio/webm",
|
||||
".mp4": "video/mp4",
|
||||
".mpga": "audio/mpeg",
|
||||
".wav": "audio/wav",
|
||||
".mpeg": "video/mpeg",
|
||||
".pdf": "application/pdf",
|
||||
".html": "text/html",
|
||||
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
||||
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
".odt": "application/vnd.oasis.opendocument.text",
|
||||
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
".xls": "application/vnd.ms-excel",
|
||||
".epub": "application/epub+zip",
|
||||
".ipynb": "application/x-ipynb+json",
|
||||
".py": "text/x-python",
|
||||
}
|
||||
|
||||
|
||||
def upload_file_storage(file, file_identifier: str):
|
||||
supabase_client: Client = get_supabase_client()
|
||||
# res = supabase_client.storage.create_bucket("quivr")
|
||||
response = None
|
||||
|
||||
try:
|
||||
response = supabase_client.storage.from_("quivr").upload(file_identifier, file)
|
||||
# Get the file extension
|
||||
_, file_extension = os.path.splitext(file_identifier)
|
||||
|
||||
# Get the MIME type for the file extension
|
||||
mime_type = mime_types.get(file_extension, "text/html")
|
||||
|
||||
response = supabase_client.storage.from_("quivr").upload(
|
||||
file_identifier, file, file_options={"content-type": mime_type}
|
||||
)
|
||||
|
||||
return response
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
|
Loading…
Reference in New Issue
Block a user