This commit is contained in:
@ -1,3 +1,4 @@
|
||||
from base64 import b64decode
|
||||
from logging import getLogger
|
||||
|
||||
from fastapi import APIRouter, Response
|
||||
@ -23,9 +24,10 @@ async def download_file(token: str):
|
||||
raise e.NotFoundException
|
||||
|
||||
data = loads(file_data)
|
||||
file_bytes = b64decode(data['data'])
|
||||
|
||||
return Response(
|
||||
content=data['data'],
|
||||
content=file_bytes,
|
||||
media_type=data['content_type'],
|
||||
headers={
|
||||
'Content-Disposition': f'attachment; filename="{data["filename"]}"'
|
||||
|
||||
@ -126,7 +126,7 @@ async def get_vaccs_report_download(
|
||||
{
|
||||
'filename': filename,
|
||||
'content_type': 'application/msword',
|
||||
'data': file_bytes,
|
||||
'data': base64.b64encode(file_bytes).decode('utf-8'),
|
||||
}
|
||||
),
|
||||
ex=600,
|
||||
@ -312,7 +312,7 @@ async def get_aemd_file_download(
|
||||
{
|
||||
'filename': filename,
|
||||
'content_type': 'application/pdf',
|
||||
'data': pdf_bytes,
|
||||
'data': base64.b64encode(pdf_bytes).decode('utf-8'),
|
||||
}
|
||||
),
|
||||
ex=600,
|
||||
|
||||
@ -634,10 +634,16 @@ class ProlongationModel(BaseModel):
|
||||
title='Дата продления до', examples=['2020-10-25']
|
||||
)
|
||||
Post: str = Field(
|
||||
default='Неизвестный врач',
|
||||
title='Врач',
|
||||
examples=['Ахсанова Р.М. (Врач общей практики (семейный врач))'],
|
||||
)
|
||||
|
||||
@field_validator('Post', mode='before')
|
||||
@classmethod
|
||||
def set_default_post(cls, v: str | None) -> str:
|
||||
return v or 'Неизвестный врач'
|
||||
|
||||
|
||||
class PatientELNModel(BaseModel):
|
||||
PatientSNILS: str | None = Field(
|
||||
|
||||
Reference in New Issue
Block a user