Im running latest v11 and struggling to find a solution to this.
I need to modify filenames of uploaded media before they are committed into the ecosystem. Essentially prefixing them with a random string to further obfuscate the URL's they are accessed on.
I've found many approaches online to acheive this including subscribing to onCreating Events but none of these appear to be in v11. Can you point me to the new methods?
which should be emitted just before the Media Item is saved, and I think allows you to manipulate the details of the file through the 'SavedEntities' property of the notification.
How to subscribe to fileupload events?
Hi all,
Im running latest v11 and struggling to find a solution to this.
I need to modify filenames of uploaded media before they are committed into the ecosystem. Essentially prefixing them with a random string to further obfuscate the URL's they are accessed on.
I've found many approaches online to acheive this including subscribing to onCreating Events but none of these appear to be in v11. Can you point me to the new methods?
Thanks! Carl
Hi cgxcc
Are you using the MediaService to save the uploaded file into Umbraco?
https://docs.umbraco.com/umbraco-cms/reference/management/services/mediaservice
or are editors just uploading new files into the Media Section?
Either way, I think you can handle the 'MediaSavingNotification'
https://docs.umbraco.com/umbraco-cms/reference/notifications/mediaservice-notifications
which should be emitted just before the Media Item is saved, and I think allows you to manipulate the details of the file through the 'SavedEntities' property of the notification.
regards
Marc
Marc, you are a gentleman and a scholar.
This link provided all the answers, thank you very much.
All the best, Carl
Ah I spoke too soon.
On further inspection it's not quite done what I thought it had.
It did indeed change the visible file name but only within Umbraco (and not in my storage account)
My media are currently being saved as follows:
/media/
Its the random 8 char string that I'm trying to make longer, or alternatively include additional random chars to the filename.png part.
Any ideas which Notification handle this?
Hi cgxcc
Sounds like you might want to implement your own mediapathscheme
https://docs.umbraco.com/umbraco-cms/extending/filesystemproviders#mediapath-scheme
This will allow you to define rules for how the media folder path is calculated...
Regards
Marc
is working on a reply...