fastapi-admin / fastapi-admin/fastapi-admin

`FileUpload`'s `save_file` function returns path incorrectly on Windows with backslash separator (due to `os.path.join`)

Aperta
#154 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
3.8k
Fork
466
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Title says it all.

When using `from fastapi_admin.file_upload import FileUpload` and it returns the save path (endpoint to fetch the file) using prefix and filename, it joins the path using `os.path.join`, which is OS-dependent. This causes the filename to contain `\` separated path on Windows.

Example:
```python
upload_face = FileUpload(
uploads_dir="./static/uploads",
prefix="/faces", # StaticFiles is mounted here
filename_generator=random_filename, # Ignore this
)
```

image

It just causes the backslash escape character sequence to mess up path when fetching images sometimes.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.