Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jakob Lithner 61 posts 264 karma points
    Mar 11, 2016 @ 14:12
    Jakob Lithner
    0

    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

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Mar 11, 2016 @ 14:49
    Jeroen Breuer
    0

    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

  • Jakob Lithner 61 posts 264 karma points
    Mar 11, 2016 @ 15:52
    Jakob Lithner
    0

    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?

  • bengan 26 posts 90 karma points
    Jul 13, 2016 @ 08:19
    bengan
    0

    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:

    • 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? ;)

    Thanks and regards,

    Ben

Please Sign in or register to post replies

Write your reply to:

Draft