I have used MediaService.Saving event with success. Now I tried to use MediaService.Deleted/MediaService.Deleting events because I want to delete media files from disk as well. But none of these events are firing. Anyone know why?
Ah, excellent answer!
I just missed that all items were moved to recycle bin first ...
This really makes sense.
And I noticed that when deleting from recycle bin, they are actually deleted from disk as well, so I don't need to intervene :)
But I noticed one peculiarity: When deleting media files from recycle bin, the Deleting and Deleted events are fired as expected. But when emptying recycle bin, these events are not fired. Do you know of any reason behind this?
I noticed the same in Umbraco 7.2.8. The documentation seems not to be correct in this case. When emptying recycle bin, the Deleted event does not fire.
That's a problem for me, because I have a special solution for Media files, that require a static URL without the dynamic Media ID in the URL path. In my solution for this I listen to the MediaService events for actions inside a certain Media folder:
On Saved event I copy the files to a custom website folder (and adapt the file path in the Umbraco Media Item)
On Deleted event I delete the file from this custom website folder
This works fine, except when empying the recycle bin by using the context menu of the recycle bin. Then the umbraco Media item is deleted without firing the Deleted event. That's a problem, because the file is still available by its URL.
Has anyone a solution for this? Could Umbraco please fix this in the future? ;)
MediaService events not firing
I have used MediaService.Saving event with success. Now I tried to use MediaService.Deleted/MediaService.Deleting events because I want to delete media files from disk as well. But none of these events are firing. Anyone know why?
Umbraco 7.4.1
Hello,
These events are only fired if you deleted them when media items are in the recyle bin. If you move them to the bin other events are fired.
Jeroen
Ah, excellent answer! I just missed that all items were moved to recycle bin first ... This really makes sense. And I noticed that when deleting from recycle bin, they are actually deleted from disk as well, so I don't need to intervene :)
But I noticed one peculiarity: When deleting media files from recycle bin, the Deleting and Deleted events are fired as expected. But when emptying recycle bin, these events are not fired. Do you know of any reason behind this?
Hi Jakob,
I noticed the same in Umbraco 7.2.8. The documentation seems not to be correct in this case. When emptying recycle bin, the Deleted event does not fire.
That's a problem for me, because I have a special solution for Media files, that require a static URL without the dynamic Media ID in the URL path. In my solution for this I listen to the MediaService events for actions inside a certain Media folder:
This works fine, except when empying the recycle bin by using the context menu of the recycle bin. Then the umbraco Media item is deleted without firing the Deleted event. That's a problem, because the file is still available by its URL.
Has anyone a solution for this? Could Umbraco please fix this in the future? ;)
Thanks and regards,
Ben
is working on a reply...