mirror of
https://github.com/langgenius/dify.git
synced 2026-05-10 05:56:31 +08:00
added check on tenant id
Signed-off-by: xr843 <137012659+xr843@users.noreply.github.com>
This commit is contained in:
parent
90fe54ca9e
commit
60f8e93ee7
@ -105,7 +105,8 @@ class FilePreviewApi(Resource):
|
||||
@account_initialization_required
|
||||
def get(self, file_id):
|
||||
file_id = str(file_id)
|
||||
text = FileService(db.engine).get_file_preview(file_id)
|
||||
_, tenant_id = current_account_with_tenant()
|
||||
text = FileService(db.engine).get_file_preview(file_id, tenant_id)
|
||||
return {"content": text}
|
||||
|
||||
|
||||
|
||||
@ -173,12 +173,16 @@ class FileService:
|
||||
|
||||
return upload_file
|
||||
|
||||
def get_file_preview(self, file_id: str):
|
||||
def get_file_preview(self, file_id: str, tenant_id: str):
|
||||
"""
|
||||
Return a short text preview extracted from a document file.
|
||||
"""
|
||||
with self._session_maker(expire_on_commit=False) as session:
|
||||
upload_file = session.scalar(select(UploadFile).where(UploadFile.id == file_id).limit(1))
|
||||
upload_file = session.scalar(
|
||||
select(UploadFile)
|
||||
.where(UploadFile.id == file_id, UploadFile.tenant_id == tenant_id)
|
||||
.limit(1)
|
||||
)
|
||||
|
||||
if not upload_file:
|
||||
raise NotFound("File not found")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user