From 104401dab9365b55b477dbe360ac2f14f1e93179 Mon Sep 17 00:00:00 2001 From: Kavalar Date: Mon, 30 Oct 2023 02:02:47 +0300 Subject: [PATCH] file mod --- server.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server.py b/server.py index 038f52d..bd2123f 100644 --- a/server.py +++ b/server.py @@ -78,12 +78,15 @@ async def create_upload_file(file: UploadFile | None, package: Annotated[str, Fo os.makedirs(dir_last) if not os.path.exists(dir_stable): os.makedirs(dir_stable) - with open(f"{dir_file}/{filename}", 'wb+') as f: + with open(f"{dir_file}/{filename}", 'r + b') as f: + f.seek(0) f.write(contents) - with open(f"{dir_last}/{filename}", 'wb+') as f: + with open(f"{dir_last}/{filename}", 'r + b') as f: + f.seek(0) f.write(contents) if stable: - with open(f"{dir_stable}/{filename}", 'wb+') as f: + with open(f"{dir_stable}/{filename}", 'r + b') as f: + f.seek(0) f.write(contents) except Exception as err: return {"message": "There was an error uploading the file, error {err}".format(err=err)}