This commit is contained in:
@ -1,5 +1,4 @@
|
||||
import base64
|
||||
import io
|
||||
from datetime import UTC, datetime
|
||||
from json import dumps
|
||||
from logging import getLogger
|
||||
@ -7,7 +6,6 @@ from secrets import token_urlsafe
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Body, Depends, UploadFile, status
|
||||
from fastapi.responses import StreamingResponse
|
||||
from orjson import loads
|
||||
|
||||
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']
|
||||
decoded = base64.b64decode(b64)
|
||||
pdf = await convert_aemd_to_pdf(decoded, docKind)
|
||||
b64_pdf = base64.b64encode(pdf).decode('utf-8')
|
||||
|
||||
return StreamingResponse(
|
||||
io.BytesIO(pdf),
|
||||
media_type='application/pdf',
|
||||
headers={
|
||||
'Content-Disposition': f'attachment; filename="{emdrId}.pdf"'
|
||||
},
|
||||
)
|
||||
return {
|
||||
'filename': f'{emdrId}.pdf',
|
||||
'content_type': 'application/pdf',
|
||||
'data': b64_pdf,
|
||||
}
|
||||
|
||||
|
||||
@router.post('/measurement', status_code=status.HTTP_202_ACCEPTED)
|
||||
|
||||
Reference in New Issue
Block a user