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:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user