Copied to clipboard

Flag this post as spam?

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


  • Björn 18 posts 158 karma points
    Mar 19, 2018 @ 08:16
    Björn
    0

    Mediaservice delete event

    Hi. I'm trying to hook into the delete media event and it works fine when I delete files and folders which are inside the recycle bin, but when I click on the recycle bin and chooses "Empty recycle bin" the event is not triggered. Anyone knows why that is?

    /Björn

            protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            MediaService.Saved += MediaServiceSaved;
            MediaService.Deleted += MediaServiceDeleted;            
        }
    
        void MediaServiceDeleted(IMediaService sender, DeleteEventArgs<IMedia> e)
        {
            foreach (var mediaItem in e.DeletedEntities)
            {
                System.Diagnostics.Debug.WriteLine("Deleting object");
            }
        }
    
  • Dave Woestenborghs 3325 posts 11170 karma points MVP 5x admin c-trib
    Mar 19, 2018 @ 08:23
    Dave Woestenborghs
    0

    Hi Björn

    You need to hook in to the EmptiedRecycleBin or EmptyingRecycleBin events of the Mediaservice.

    See : https://our.umbraco.org/apidocs/csharp/api/Umbraco.Core.Services.MediaService.html

    Dave

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies