backend: complete file uploading

This commit is contained in:
OleSTEEP 2025-10-05 20:18:05 +03:00
parent da077519fe
commit 23a00d2c06
3 changed files with 51 additions and 15 deletions

View file

@ -24,3 +24,11 @@ def save_image(img: bytes, dir: str, name: str) -> int:
with open(Path(path, name+'.jpg'), "wb") as file:
file.write(img)
return len(img)
def save_file(file_b: bytes, dir: str, name: str) -> int:
path = asset(dir)
path.mkdir(exist_ok=True)
with open(Path(path, name+'.jpg'), "wb") as file:
file.write(file_b)
return len(file_b)