Добавлен роутер на скачивание файлов
All checks were successful
Build And Push / publish (push) Successful in 2m44s
All checks were successful
Build And Push / publish (push) Successful in 2m44s
This commit is contained in:
@ -5,7 +5,7 @@ from logging import getLogger
|
||||
from secrets import token_urlsafe
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Body, Depends, Response, UploadFile, status
|
||||
from fastapi import APIRouter, Body, Depends, UploadFile, status
|
||||
from orjson import loads
|
||||
|
||||
from apps.remd.dependencies import convert_aemd_to_pdf, get_parsable_ids
|
||||
@ -119,12 +119,21 @@ async def get_vaccs_report_download(
|
||||
file_bytes = base64.b64decode(file.content)
|
||||
filename = f'vaccs_report_{resultId or user.vita_id}.doc'
|
||||
|
||||
return Response(
|
||||
content=file_bytes,
|
||||
media_type='application/msword',
|
||||
headers={'Content-Disposition': f'attachment; filename="{filename}"'},
|
||||
temp_link_token = token_urlsafe(32)
|
||||
await cache.set(
|
||||
f'download:{temp_link_token}',
|
||||
dumps(
|
||||
{
|
||||
'filename': filename,
|
||||
'content_type': 'application/msword',
|
||||
'data': file_bytes,
|
||||
}
|
||||
),
|
||||
ex=600,
|
||||
)
|
||||
|
||||
return s.DownloadFile(link=temp_link_token)
|
||||
|
||||
|
||||
@router.get('/getMedExamDict')
|
||||
async def get_med_exam_dict(user: Annotated[User, Depends(login)]):
|
||||
@ -296,12 +305,21 @@ async def get_aemd_file_download(
|
||||
pdf_bytes = await convert_aemd_to_pdf(decoded, docKind)
|
||||
filename = f'{emdrId}.pdf'
|
||||
|
||||
return Response(
|
||||
content=pdf_bytes,
|
||||
media_type='application/pdf',
|
||||
headers={'Content-Disposition': f'attachment; filename="{filename}"'},
|
||||
temp_link_token = token_urlsafe(32)
|
||||
await cache.set(
|
||||
f'download:{temp_link_token}',
|
||||
dumps(
|
||||
{
|
||||
'filename': filename,
|
||||
'content_type': 'application/pdf',
|
||||
'data': pdf_bytes,
|
||||
}
|
||||
),
|
||||
ex=600,
|
||||
)
|
||||
|
||||
return s.DownloadFile(link=temp_link_token)
|
||||
|
||||
|
||||
@router.post('/measurement', status_code=status.HTTP_202_ACCEPTED)
|
||||
async def measurement(
|
||||
|
||||
Reference in New Issue
Block a user