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
This commit is contained in:
Pavel Vesely
2020-12-06 16:09:46 +01:00
parent 1968b0283d
commit 14f8155df6
2 changed files with 25 additions and 22 deletions

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.StaticFiles;
namespace Oqtane.Extensions
{
@ -11,7 +12,20 @@ namespace Oqtane.Extensions
{
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;
}
}
}