Pridani sitemap, fix flake
This commit is contained in:
+8
-3
@@ -2,18 +2,23 @@ import os
|
||||
import re
|
||||
import uuid
|
||||
from strawberry.file_uploads import Upload
|
||||
|
||||
from utils.file import check_directories
|
||||
|
||||
|
||||
async def handle_file_upload(file: Upload, path: str, filename_maxlength: int = 64, uid_prefix: bool = True, overwrite: bool = True) -> str:
|
||||
async def handle_file_upload(
|
||||
file: Upload,
|
||||
path: str,
|
||||
filename_maxlength: int = 64,
|
||||
uid_prefix: bool = True,
|
||||
overwrite: bool = True
|
||||
) -> str:
|
||||
check_directories(path)
|
||||
|
||||
prefix = f"{uuid.uuid4()}-" if uid_prefix else ""
|
||||
filename = f"{prefix}{file.filename}"[-1 * filename_maxlength:]
|
||||
|
||||
# sanitize filename
|
||||
filename = re.sub('[^\w_. -]', '', filename).replace(" ", "-")
|
||||
filename = re.sub(r'[^\w_. -]', '', filename).replace(" ", "-")
|
||||
|
||||
target_path = f"{path}/{filename}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user