fix(web): allow serving all file types

fix #459
This commit is contained in:
genteure 2023-02-08 11:59:49 +08:00
parent f8a66047cb
commit 80b8b6bb51

View File

@ -196,6 +196,14 @@ namespace BililiveRecorder.Web
ctp.Mappings[".mjs"] = "text/javascript; charset=utf-8"; ctp.Mappings[".mjs"] = "text/javascript; charset=utf-8";
ctp.Mappings[".json"] = "application/json; charset=utf-8"; ctp.Mappings[".json"] = "application/json; charset=utf-8";
ctp.Mappings[".mkv"] = "video/x-matroska";
ctp.Mappings[".mk3d"] = "video/x-matroska";
ctp.Mappings[".mka"] = "audio/x-matroska";
ctp.Mappings[".mks"] = "video/x-matroska";
ctp.Mappings[".srt"] = "text/plain";
ctp.Mappings[".ass"] = "text/plain";
ctp.Mappings[".ssa"] = "text/plain";
var compositeFileProvider = app.ApplicationServices.GetRequiredService<CompositeFileProvider>(); var compositeFileProvider = app.ApplicationServices.GetRequiredService<CompositeFileProvider>();
var sharedStaticFiles = new SharedOptions() var sharedStaticFiles = new SharedOptions()
{ {
@ -224,10 +232,16 @@ namespace BililiveRecorder.Web
RequestPath = "/file", RequestPath = "/file",
RedirectToAppendTrailingSlash = true, RedirectToAppendTrailingSlash = true,
}; };
app.UseStaticFiles(new StaticFileOptions(sharedRecordingFiles)).UseDirectoryBrowser(new DirectoryBrowserOptions(sharedRecordingFiles) app
{ .UseStaticFiles(new StaticFileOptions(sharedRecordingFiles)
Formatter = new BililiveRecorderDirectoryFormatter() {
}); ContentTypeProvider = ctp,
ServeUnknownFileTypes = true,
})
.UseDirectoryBrowser(new DirectoryBrowserOptions(sharedRecordingFiles)
{
Formatter = new BililiveRecorderDirectoryFormatter(),
});
} }
} }
catch (Exception) { } catch (Exception) { }