From 08494058e9e9affb7954f5b0df8e4c43d0452254 Mon Sep 17 00:00:00 2001 From: Jyong <76649700+JohnJyong@users.noreply.github.com> Date: Tue, 26 Dec 2023 15:06:44 +0800 Subject: [PATCH] fix file type not support when preview (#1841) Co-authored-by: jyong --- api/services/file_service.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api/services/file_service.py b/api/services/file_service.py index 27f9527134..fb61bfa9be 100644 --- a/api/services/file_service.py +++ b/api/services/file_service.py @@ -133,7 +133,15 @@ class FileService: # extract text from file extension = upload_file.extension - if extension.lower() not in ALLOWED_EXTENSIONS: + etl_type = current_app.config['ETL_TYPE'] + if etl_type == 'Unstructured': + allowed_extensions = ['txt', 'markdown', 'md', 'pdf', 'html', 'htm', 'xlsx', + 'docx', 'csv', 'eml', 'msg', 'pptx', 'ppt', 'xml', + 'jpg', 'jpeg', 'png', 'webp', 'gif', 'svg'] + else: + allowed_extensions = ['txt', 'markdown', 'md', 'pdf', 'html', 'htm', 'xlsx', 'docx', 'csv', + 'jpg', 'jpeg', 'png', 'webp', 'gif', 'svg'] + if extension.lower() not in allowed_extensions: raise UnsupportedFileTypeError() text = FileExtractor.load(upload_file, return_text=True)