oqtane.framework/Oqtane.Server/Extensions/StringExtensions.cs
Pavel Vesely 14f8155df6 FileController fix
- using PhysicalFile framework method (current implementation causes file locks and 500 error at heavy load)
- Add correct mimetype to header based on file extension
2020-12-06 16:23:28 +01:00

32 lines
769 B
C#

using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.StaticFiles;
namespace Oqtane.Extensions
{
public static class StringExtensions
{
public static bool StartWithAnyOf(this string s, IEnumerable<string> list)
{
if (s == null)
{
return false;
}
return list.Any(f => s.StartsWith(f));
}
public static string GetMimeType(this string fileName)
{
var provider = new FileExtensionContentTypeProvider();
if (!provider.TryGetContentType(fileName, out var contentType))
{
contentType = "application/octet-stream";
}
return contentType;
}
}
}