Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nb-programmer opened this issue Feb 3, 2024 · 0 comments

Comments

@nb-programmer
Copy link

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
)
image

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant