backend: complete file uploading
This commit is contained in:
parent
da077519fe
commit
23a00d2c06
3 changed files with 51 additions and 15 deletions
|
@ -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)
|
Loading…
Add table
Add a link
Reference in a new issue