Skip to content

Prevent ImageField from overwriting existing files#7577

Open
lacatoire wants to merge 4 commits intoEasyCorp:5.xfrom
lacatoire:fix/imagefield-prevent-overwrite
Open

Prevent ImageField from overwriting existing files#7577
lacatoire wants to merge 4 commits intoEasyCorp:5.xfrom
lacatoire:fix/imagefield-prevent-overwrite

Conversation

@lacatoire
Copy link
Copy Markdown
Contributor

The default upload_validate callable in FileUploadType checks file_exists() to avoid collisions, but it only received the file basename, so the check was always false and existing files were silently overwritten.

StringToFileTransformer now passes the full upload_dir + filename path to upload_validate and strips the prefix from the returned value, restoring the intended collision detection for both local and Flysystem storage.

Fixes #7525

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

Successfully merging this pull request may close these issues.

ImageField overwrites existing images

1 participant