Add API for moving files (#1016)

### What problem does this PR solve?

Add backend API support for moving files into other directory

### Type of change
- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
Zhedong Cen
2024-05-31 18:11:25 +08:00
committed by GitHub
parent c58a1c48eb
commit 4ec845c0a6
2 changed files with 32 additions and 1 deletions

View File

@ -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"]})
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)!")