Патч
All checks were successful
Build And Push / publish (push) Successful in 1m20s

This commit is contained in:
2025-12-02 12:08:38 +03:00
parent 0b907afec3
commit 9e735c2cc6

View File

@ -1,5 +1,4 @@
import base64 import base64
import io
from datetime import UTC, datetime from datetime import UTC, datetime
from json import dumps from json import dumps
from logging import getLogger from logging import getLogger
@ -7,7 +6,6 @@ from secrets import token_urlsafe
from typing import Annotated from typing import Annotated
from fastapi import APIRouter, Body, Depends, UploadFile, status from fastapi import APIRouter, Body, Depends, UploadFile, status
from fastapi.responses import StreamingResponse
from orjson import loads from orjson import loads
from apps.remd.dependencies import convert_aemd_to_pdf, get_parsable_ids from apps.remd.dependencies import convert_aemd_to_pdf, get_parsable_ids
@ -248,14 +246,13 @@ async def get_aemd_file(
b64 = loads(data)['data'] b64 = loads(data)['data']
decoded = base64.b64decode(b64) decoded = base64.b64decode(b64)
pdf = await convert_aemd_to_pdf(decoded, docKind) pdf = await convert_aemd_to_pdf(decoded, docKind)
b64_pdf = base64.b64encode(pdf).decode('utf-8')
return StreamingResponse( return {
io.BytesIO(pdf), 'filename': f'{emdrId}.pdf',
media_type='application/pdf', 'content_type': 'application/pdf',
headers={ 'data': b64_pdf,
'Content-Disposition': f'attachment; filename="{emdrId}.pdf"' }
},
)
@router.post('/measurement', status_code=status.HTTP_202_ACCEPTED) @router.post('/measurement', status_code=status.HTTP_202_ACCEPTED)