Has anyone had success configuring custom MIME types on Umbraco Cloud?
A client is uploading a file with an extension that .NET does not recognize (in this case, .epr) to the Media library. The upload itself completes successfully, but when attempting to access the file afterward, it results in a 404 error. The file is visible in blob storage when I connect with Azure Storage Explorer.
I have already tried registering the MIME type in the web.config:
Just be careful as think you’ll replace any other modifications by packages/composers
Below is a previous solution to just add your new ones… though I think that still has a caveat, in that it will be last past the post that wins on any duplicates..
provider.Mappings.Add would throw an error for existing duplicates. new FileExtensionContentTypeProvider() brings 400 default mime types…
using Microsoft.AspNetCore.StaticFiles;
using Umbraco.Cms.Core.Composing;
public class RiveStaticFileComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.Services.Configure<StaticFileOptions>(options =>
{
var provider = options.ContentTypeProvider as FileExtensionContentTypeProvider
?? new FileExtensionContentTypeProvider();
provider.Mappings[".riv"] = "application/octet-stream";
options.ContentTypeProvider = provider;
});
}
}