artgris / FileManagerBundle

FileManager is a simple Multilingual File Manager Bundle for Symfony
MIT License
171 stars 89 forks source link

Removal of special characters from folder and file names #88

Open twin-elements opened 3 years ago

twin-elements commented 3 years ago

Hi. I need to be able to remove special characters and spaces when creating a new folder or a new file. Unfortunately, in Poland, some servers have a problem with paths that contain Polish characters. How can I do this?

rmekni commented 2 years ago

hey @twin-elements , did you find a way to do it?

twin-elements commented 2 years ago

Hi @rmekni The only quick solution is to overwrite the controller and block a current version of the package in composer.json. I will try to finish the modification to this manager soon and propose the changes to @artgris

rmekni commented 2 years ago

thanks @twin-elements for your reply, For me, for files, just overrided the main controller uploadFileAction and UploadHandler's trim_file_name function to remove special chars, for folders, indexAction of the main controller, i created a helper that creates a yaml file that contains the original name and the filtered one then i just search for the original name for manager but i keep the filtered one for the web url

Martin1982 commented 2 years ago

There are already some events available in the bundle where you can handle such things for some cases. The one I don't see is for directories, you might want to create a PR where you dispatch an event at https://github.com/artgris/FileManagerBundle/blob/643db45abac16bd84ed8a5ee53aca831a8cb1bc1/Controller/ManagerController.php#L177

And add a new event to https://github.com/artgris/FileManagerBundle/blob/master/Event/FileManagerEvents.php called PRE_CREATE_FOLDER

In your own application you can listen for this event and adjust the characters as required.