Copied to clipboard

Flag this post as spam?

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

  • Jesper Weber 33 posts 98 karma points c-trib
    5 days ago
    Jesper Weber

    Set ContentType in MediaService.Saving event


    I have created a custom media type and hooked in to the MediaService.Saving event.

    When a file is uploaded I want to set the content type based on the file extension. How ever at that point Umbraco has already given media a content type.

        public void Initialize()
            MediaService.Saving += MediaService_Saving;
        private void MediaService_Saving(IMediaService sender, SaveEventArgs<IMedia> e)
            foreach (var mediaItem in e.SavedEntities)
                var contentTypeAlias = mediaItem.ContentType.Alias;

    How do I change the content type or hook in earlier to set the content type my self?

Please Sign in or register to post replies

Write your reply to: