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:
KevinHuSh
2024-04-28 09:57:40 +08:00
committed by GitHub
parent f1c98aad6b
commit 944776f207
6 changed files with 36 additions and 11 deletions

View File

@ -328,12 +328,12 @@ def rename():
# @login_required
def get(file_id):
try:
e, doc = FileService.get_by_id(file_id)
e, file = FileService.get_by_id(file_id)
if not e:
return get_data_error_result(retmsg="Document not found!")
response = flask.make_response(MINIO.get(doc.parent_id, doc.location))
ext = re.search(r"\.([^.]+)$", doc.name)
response = flask.make_response(MINIO.get(file.parent_id, file.location))
ext = re.search(r"\.([^.]+)$", file.name)
if ext:
if doc.type == FileType.VISUAL.value:
response.headers.set('Content-Type', 'image/%s' % ext.group(1))