Created FileList with ability to set used files

This commit is contained in:
schnulller
2022-06-07 16:14:27 +02:00
parent 715cf167a0
commit d8155e26f6
44 changed files with 1468 additions and 119 deletions

View File

@@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Net.Http.Headers;
using HaWeb.Models;
using System.Text;
public static class XMLFileHelpers {
// File Signatures Database (https://www.filesignatures.net/)
@@ -199,6 +200,20 @@ public static class XMLFileHelpers {
return null;
}
public static string? StreamToString(System.IO.Stream stream, ModelStateDictionary modelState) {
string? ret = null;
try {
using (var rd = new StreamReader(stream, Encoding.UTF8)) {
ret = rd.ReadToEnd();
return ret;
}
}
catch (Exception ex) {
modelState.AddModelError("Error", "Reading of the message failed with " + ex.Message);
return null;
}
}
private static bool IsValidFileExtensionAndSignature(string fileName, Stream data, string[] permittedExtensions) {
if (string.IsNullOrEmpty(fileName) || data == null || data.Length == 0)
return false;