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?
Set ContentType in MediaService.Saving event
Hi,
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.
How do I change the content type or hook in earlier to set the content type my self?
is working on a reply...
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.