Ukladani letu, query na seznam letist

This commit is contained in:
Michal Kváček
2023-06-06 07:34:45 +02:00
parent 014a999055
commit 69d30c8654
12 changed files with 301 additions and 64 deletions
+23
View File
@@ -0,0 +1,23 @@
import os
import uuid
from strawberry.file_uploads import Upload
def check_directories(path: str):
if not os.path.isdir(path):
os.makedirs(path)
async def handle_img_upload(file: Upload, path: str):
check_directories(path)
filename = f"{uuid.uuid4()}-{file.filename}"
content = await file.read()
image = open(path + "/" + filename, "wb")
image.write(content)
image.close()
def delete_file(path: str, silent: bool = False):
os.remove(path)