shorten filenames
This commit is contained in:
parent
c6c6bd7f0b
commit
f6cbd2aeb1
1 changed files with 3 additions and 1 deletions
|
@ -58,11 +58,13 @@ def normalize_filename(filename: str):
|
||||||
'ciao'
|
'ciao'
|
||||||
>>> normalize_filename("Hello, 42 worlds!")
|
>>> normalize_filename("Hello, 42 worlds!")
|
||||||
'Hello42worlds'
|
'Hello42worlds'
|
||||||
|
>>> normalize_filename("Hey, do you want to hear my story?" * 10)
|
||||||
|
'HeydoyouwanttohearmystoryHeydo'
|
||||||
"""
|
"""
|
||||||
return "".join(
|
return "".join(
|
||||||
c for c in filename
|
c for c in filename
|
||||||
if c.isalnum() or c in '-_'
|
if c.isalnum() or c in '-_'
|
||||||
)
|
)[:40]
|
||||||
|
|
||||||
@app.post("/upload")
|
@app.post("/upload")
|
||||||
async def upload(
|
async def upload(
|
||||||
|
|
Loading…
Reference in a new issue