fastapi-admin / fastapi-admin/fastapi-admin

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

Open
#154 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
3.8k
Forks
466
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.