RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Add API for moving files (#1016)
Zhedong Cen4ec845c0a6b9
diff --git a/api/apps/file_app.py b/api/apps/file_app.pyindex 987321ee18..cd4e0be204 100644--- a/api/apps/file_app.py+++ b/api/apps/file_app.py@@ -343,5 +343,27 @@ def get(file_id):'application/%s' %ext.group(1))return response+ except Exception as e:+ return server_error_response(e)+[email protected]('/mv', methods=['POST'])+@login_required+@validate_request("src_file_ids", "dest_file_id")+def move():+ req = request.json+ try:+ file_ids = req["src_file_ids"]+ parent_id = req["dest_file_id"]+ for file_id in file_ids:+ e, file = FileService.get_by_id(file_id)+ if not e:+ return get_data_error_result(retmsg="File or Folder not found!")+ if not file.tenant_id:+ return get_data_error_result(retmsg="Tenant not found!")+ fe, _ = FileService.get_by_id(parent_id)+ if not fe:+ return get_data_error_result(retmsg="Parent Folder not found!")+ FileService.move_file(file_ids, parent_id)+ return get_json_result(data=True)except Exception as e:return server_error_response(e)\ No newline at end of filediff --git a/api/db/services/file_service.py b/api/db/services/file_service.pyindex e551509cc8..7b9ecd2c5d 100644--- a/api/db/services/file_service.py+++ b/api/db/services/file_service.py@@ -304,4 +304,13 @@ class FileService(CommonService):"source_type": FileSource.KNOWLEDGEBASE}cls.save(**file)- File2DocumentService.save(**{"id": get_uuid(), "file_id": file["id"], "document_id": doc["id"]})\ No newline at end of file+ File2DocumentService.save(**{"id": get_uuid(), "file_id": file["id"], "document_id": doc["id"]})++ @classmethod+ @DB.connection_context()+ def move_file(cls, file_ids, folder_id):+ try:+ cls.filter_update((cls.model.id << file_ids, ), { 'parent_id': folder_id })+ except Exception as e:+ print(e)+ raise RuntimeError("Database error (File move)!")\ No newline at end of file