From d9d88302f3ab3171327ddf24f59db1c628dfb7d7 Mon Sep 17 00:00:00 2001 From: Miwory Date: Thu, 16 Apr 2026 18:28:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=8B=D1=82=D0=BA=D0=B0=20?= =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=D0=B0=20.doc=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- src/apps/download/v1/router.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 52a3ccb..96a20cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "HospitalAssistantBackend" -version = "1.5.10" +version = "1.5.11" description = "Backend for Hospital Assistant" readme = "README.md" requires-python = ">=3.13,<3.14" diff --git a/src/apps/download/v1/router.py b/src/apps/download/v1/router.py index 99bc037..c8787ec 100644 --- a/src/apps/download/v1/router.py +++ b/src/apps/download/v1/router.py @@ -24,12 +24,15 @@ async def download_file(token: str): raise e.NotFoundException data = loads(file_data) - file_bytes = b64decode(data['data']) + file_name = data['filename'] + file_bytes = b64decode(data['data'].strip(), validate=True) + print(f'Header: {file_bytes[:8].hex(" ")}') return Response( content=file_bytes, media_type=data['content_type'], headers={ - 'Content-Disposition': f'attachment; filename="{data["filename"]}"' + 'Content-Disposition': f'attachment; filename="{file_name}"', + 'Content-Length': str(len(file_bytes)), }, )