Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix file type not support when preview (#1841)

Jyong08494058e9e9
diff --git a/api/services/file_service.py b/api/services/file_service.py
index 27f95271342..fb61bfa9be0 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)