fastapi-admin
fastapi-admin copied to clipboard
`FileUpload`'s `save_file` function returns path incorrectly on Windows with backslash separator (due to `os.path.join`)
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:
upload_face = FileUpload(
uploads_dir="./static/uploads",
prefix="/faces", # StaticFiles is mounted here
filename_generator=random_filename, # Ignore this
)
It just causes the backslash escape character sequence to mess up path when fetching images sometimes.