diff --git a/apps/knowledge/serializers/knowledge_workflow.py b/apps/knowledge/serializers/knowledge_workflow.py index eec20b2ce34..61da630c550 100644 --- a/apps/knowledge/serializers/knowledge_workflow.py +++ b/apps/knowledge/serializers/knowledge_workflow.py @@ -265,6 +265,18 @@ def upload_document(self, instance: Dict, user, with_valid=True): ), ) work_flow_manage.run() + # 需要把文件改成永久文件 + data_source = instance.get("data_source") or {} + file_ids = [item.get("file_id") for item in data_source.get("file_list") or [] if item.get("file_id")] + knowledge_id = str(self.data.get("knowledge_id")) + file_list = list(QuerySet(File).filter(id__in=file_ids)) + for file in file_list: + meta = dict(file.meta or {}) + meta.update(debug=False, knowledge_id=knowledge_id) + file.source_type = FileSourceType.KNOWLEDGE.value + file.source_id = knowledge_id + file.meta = meta + QuerySet(File).bulk_update(file_list, ["source_type", "source_id", "meta"]) return { "id": knowledge_action_id, "knowledge_id": self.data.get("knowledge_id"), diff --git a/ui/src/views/document/ImportWorkflowDocument.vue b/ui/src/views/document/ImportWorkflowDocument.vue index 7083983252c..4a3ffebacd2 100644 --- a/ui/src/views/document/ImportWorkflowDocument.vue +++ b/ui/src/views/document/ImportWorkflowDocument.vue @@ -73,8 +73,8 @@ provide( (file: any, onProgress?: (percent: number, event: any) => void, loading?: Ref) => { return applicationApi.postUploadFileProgress( file, - id as string, - 'KNOWLEDGE', + 'TEMPORARY_120_MINUTE', + 'TEMPORARY_120_MINUTE', onProgress, loading, ) diff --git a/ui/src/views/document/upload/UploadComponent.vue b/ui/src/views/document/upload/UploadComponent.vue index 8916cc8ba30..a99c2d92e83 100644 --- a/ui/src/views/document/upload/UploadComponent.vue +++ b/ui/src/views/document/upload/UploadComponent.vue @@ -448,8 +448,8 @@ const uploadFile = (item: any) => { item.aborted = false const res: any = applicationApi.postUploadFileProgress( item.raw, - id as string, - 'KNOWLEDGE', + 'TEMPORARY_120_MINUTE', + 'TEMPORARY_120_MINUTE', (percent: number) => { item.percentage = percent },