From bb6d8e1ad475d64335efc4c0ca15445d274eb793 Mon Sep 17 00:00:00 2001 From: Alexander Goscinski Date: Thu, 21 Nov 2024 12:37:29 +0100 Subject: [PATCH] Remove redundant streaming in download of file In PR #71 a streaming mechanism has been implemented for the endpoint `/nodes/{nodes_id}/download`, this however is already taken care by FastAPI StreamingResponse and is therefore redundant and can be removed. --- aiida_restapi/routers/nodes.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/aiida_restapi/routers/nodes.py b/aiida_restapi/routers/nodes.py index f3ac146..5f17a4e 100644 --- a/aiida_restapi/routers/nodes.py +++ b/aiida_restapi/routers/nodes.py @@ -15,7 +15,6 @@ from pydantic import ValidationError from aiida_restapi import models, resources -from aiida_restapi.config import DOWNLOAD_CHUNK_SIZE from .auth import get_current_active_user @@ -73,8 +72,7 @@ async def download_node(nodes_id: int, download_format: Optional[str] = None) -> def stream() -> Generator[bytes, None, None]: with io.BytesIO(exported_bytes) as handler: - while chunk := handler.read(DOWNLOAD_CHUNK_SIZE): - yield chunk + yield from handler return StreamingResponse(stream(), media_type=f'application/{download_format}')