Add custom file extension to media field template

Hi,

How can we add custom file types/extension to “File extensions” field?
Are these options baked into the Angular “frontend” solution for backoffice or in the database?

The file extensions we need is .stp and .step for now.

Been looking through the documentation and forum, but have not been able to find anything.

Litium version: 8.8.0

The file extensions is populated from the Litium.Application.Media.MimeExtensionHelper. It looks like that the service not can be decorated but it’s possible to replace with your own implementation inheriting the service. Use the litium/plugin/types/remove section in the appsettings to remove the default one.

Hmm,

I was not able to figure it out right now, I’m fairly new to both Litium and C# and probably need some assistance to implement.

Added the Litium/Plugins/Types/Remove config to appsettings.Development.json, not entirely sure how it’s suppose to be in Litium 8’s appsettings, seen some examples of Litium 7 with Web.config xml files and tried to replicate that, but didn’t seem to do much.

Also added an my own class, extending the Litium.Application.Media.MimeExtensionHelper class, made a bit of adjustments, removed unnecessary code, not sure what’s missing right now.

Here’s an example of the latest attempt.

using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using Litium.Application.Media;

namespace Litium.Accelerator.Mvc.Media
{
  public class MimeExtensionHelperExt : MimeExtensionHelper
  {
    private readonly RetryableLazy<MimeTypeCollectionExt> _extensionTypes;

    public MimeExtensionHelperExt(ILogger<MimeExtensionHelper> logger) : base(logger)
    {
      _extensionTypes = new RetryableLazy<MimeTypeCollectionExt>((Func<MimeTypeCollectionExt>) (() => new MimeTypeCollectionExt(logger)));
    }

    internal class MimeTypeCollectionExt : List<MimeTypeInfo>
    {
      public MimeTypeCollectionExt(ILogger logger)
      {
        Add(new MimeTypeInfo("application/STEP", new List<string>(new []
        {
          ".stp",
          ".step"
        })));
      }
    }
  }
}

Are you able to see something obvious that I missed? @patric.forsgard

// JT

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.