mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
fix bug about fetching file from minio (#574)
### What problem does this PR solve? ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -18,6 +18,8 @@ from datetime import datetime
|
||||
from api.db.db_models import DB
|
||||
from api.db.db_models import File, Document, File2Document
|
||||
from api.db.services.common_service import CommonService
|
||||
from api.db.services.document_service import DocumentService
|
||||
from api.db.services.file_service import FileService
|
||||
from api.utils import current_timestamp, datetime_format
|
||||
|
||||
|
||||
@ -64,3 +66,18 @@ class File2DocumentService(CommonService):
|
||||
num = cls.model.update(obj).where(cls.model.id == file_id).execute()
|
||||
e, obj = cls.get_by_id(cls.model.id)
|
||||
return obj
|
||||
|
||||
@classmethod
|
||||
@DB.connection_context()
|
||||
def get_minio_address(cls, doc_id=None, file_id=None):
|
||||
if doc_id:
|
||||
ids = File2DocumentService.get_by_document_id(doc_id)
|
||||
else:
|
||||
ids = File2DocumentService.get_by_file_id(file_id)
|
||||
if ids:
|
||||
e, file = FileService.get_by_id(ids[0].file_id)
|
||||
return file.parent_id, file.location
|
||||
else:
|
||||
assert doc_id, "please specify doc_id"
|
||||
e, doc = DocumentService.get_by_id(doc_id)
|
||||
return doc.kb_id, doc.location
|
||||
|
||||
Reference in New Issue
Block a user