From 7e8afb21ecef41e8653f23b69daaa7008fb9c16d Mon Sep 17 00:00:00 2001 From: Kavalar Date: Mon, 30 Oct 2023 02:15:27 +0300 Subject: [PATCH] fix save file --- server.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/server.py b/server.py index bd2123f..7b31589 100644 --- a/server.py +++ b/server.py @@ -78,16 +78,13 @@ 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}", 'r + b') as f: - f.seek(0) - f.write(contents) - with open(f"{dir_last}/{filename}", 'r + b') as f: - f.seek(0) - f.write(contents) + with open(f"{dir_file}/{filename}", 'w') as f: + f.write(str(contents)) + with open(f"{dir_last}/{filename}", 'w') as f: + f.write(str(contents)) if stable: - with open(f"{dir_stable}/{filename}", 'r + b') as f: - f.seek(0) - f.write(contents) + with open(f"{dir_stable}/{filename}", 'w') as f: + f.write(str(contents)) except Exception as err: return {"message": "There was an error uploading the file, error {err}".format(err=err)} finally: