
- using PhysicalFile framework method (current implementation causes file locks and 500 error at heavy load) - Add correct mimetype to header based on file extension
32 lines
769 B
C#
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;
|
|
}
|
|
}
|
|
}
|