I want to be able to use a specific type of file extension called .step
I suspect that I need to add those to the Media => Field Templates => Other but I’m rather unsure as to where to do so since they don’t exist in the list of options here to pick from.
Any tips/help with this would be greatly appreciated.
We are looking into a solution for this. Most probably we will introduce a way for partners to define allowed file types for a project, by specifying a list in app settings.
@ludvig.block Is there any workaround we can do right now?
We are going really short on time right now and this is blocking a release on our side. Worst case is that we need to downgrade the upgrade we have done, I’m not even sure if that’s possible to do?
Okay so after some head scratching this is what I’ve done so far:
I created this class to extend the MimeTypes.
using System.Collections.Generic;
using Litium.Application.Media;
using Microsoft.Extensions.Logging;
namespace Litium.Accelerator.Mvc.Extensions
{
public class ExtendedMimeExtensionHelper : MimeExtensionHelper
{
private readonly List<MimeTypeInfo> _customMimeTypes = new List<MimeTypeInfo>
{
new MimeTypeInfo("application/step", new List<string> { ".step" }),
new MimeTypeInfo("application/sldasm", new List<string> { ".sldasm" }),
new MimeTypeInfo("application/sldprt", new List<string> { ".sldprt" })
};
public ExtendedMimeExtensionHelper(ILogger<MimeExtensionHelper> logger) : base(logger) { }
public override string FindExtension(string mimeType)
{
foreach (var customMimeType in _customMimeTypes)
{
if (mimeType == customMimeType.MimeType)
return customMimeType.Extensions[0];
}
return base.FindExtension(mimeType);
}
public override string FindMime(string extension)
{
foreach (var customMimeType in _customMimeTypes)
{
if (customMimeType.Extensions.Contains(extension))
return customMimeType.MimeType;
}
return base.FindMime(extension);
}
public override IEnumerable<MimeTypeInfo> GetAll()
{
var baseList = new List<MimeTypeInfo>(base.GetAll());
baseList.AddRange(_customMimeTypes);
return baseList;
}
}
}