shorten filenames

This commit is contained in:
boyska 2024-12-07 19:46:28 +01:00
parent c6c6bd7f0b
commit f6cbd2aeb1

View file

@ -58,11 +58,13 @@ def normalize_filename(filename: str):
'ciao'
>>> normalize_filename("Hello, 42 worlds!")
'Hello42worlds'
>>> normalize_filename("Hey, do you want to hear my story?" * 10)
'HeydoyouwanttohearmystoryHeydo'
"""
return "".join(
c for c in filename
if c.isalnum() or c in '-_'
)
)[:40]
@app.post("/upload")
async def upload(