Upload Plugin: Filenames Automatically Replacing - with _ (Needs Config Option)
Matt Delashaw
Expected Behavior
Filenames should remain unchanged during upload.
If modifications are necessary, there should be a config option to allow users to choose.
Actual Behavior
Strapi forces - to _ replacements on filenames.
Overrides to formatFileInfo(), uploadFileAndPersist(), and other lifecycle hooks do not work.
Filenames appear correct in the UI but are stored incorrectly in the database and on disk.
Steps to Reproduce
Upload a file with the name my-awesome-image.jpg
Strapi stores it as my_awesome_image.jpg
No configuration options or service overrides prevent this.
Proposed Fix
Introduce a keepOriginalFilename config option in config/plugins.ts.
Allow developers to override filename processing before Strapi modifies it.
Write a notification to say, hey, if you use "-" in filenames, it may break your ancient Oracle or whatever you need to. I don't want my filenames to always have an "_", and I would like to be able to risk uploading a file overwrite if the "hash" is excluded from the suffix. that it very poorly named btw. if you stick with hash, it should be an actual hash of the file, not just a random string. The
string.ts
in the core/utils that is being used, has this ability from what i have seen. its just not being implemented.