Ukladani letu, query na seznam letist
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user