Override the renaming of file uploads to the file/media library?
Hello. I've the following issues with the media and file libraries.
I need to upload different subtitle files associated with a Video model, which are to be associated with different translations. We've already been having problems with tildes and other characters as reported on issue #78 . But we'd love to actually rename the whole uploaded file, so if we know it's associated with a concrete model and translation, we can rename the file as something like subs.en.vtt or subs.it.vtt .
Is there already any way to do this renaming that I've missed other than overwriting the twill files themselves?
Thanks in advance!
Hi @tomascardenal, sorry for the delay on this one, time flies sometimes...
It should be possible to add some sort of hook for you to be able to rename those files when they are uploaded. It seems like you want to rename the file depending on the model it has been attached to though. What would happen if you attach that same file to another model? Or if you upload that file while not being on the form screen?
We actually solved this using Laravel observers https://laravel.com/docs/5.8/eloquent#observers and detecting when a file or a media model is being saved, to take the name, extension, and all those metadata. Thanks for answering, though. I do know time flies, and I seeing all the feedback you're getting I can see why you can sometimes feel overwhelmed