From 2795f9b5fd2450c5688ce58338d56c1eccc07ed9 Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Wed, 2 Mar 2022 23:11:38 +0300 Subject: [PATCH] Add buffered uploaded file read --- app/main.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/main.py b/app/main.py index 18bd26c..d90b08c 100644 --- a/app/main.py +++ b/app/main.py @@ -35,12 +35,11 @@ async def convert( converted_temp_filename = str(temp_uuid) + "." + format async with aiofiles.open(temp_filename, "wb") as f: - content = await file.read() + while (content := await file.read(1024)): + if isinstance(content, str): + content = content.encode() - if isinstance(content, str): - content = content.encode() - - await f.write(content) + await f.write(content) proc = await asyncio.create_subprocess_exec( "./bin/fb2c",