Define TryGetMimeType & GetMimeType
HunteRoi opened this issue · 1 comments
Good afternoon!
I came across your repository while searching for a solution to make sure that the filename of a file matches its content-type.
I was wondering if it would be possible to implement TryGetMimeType
& GetMimeType
using your private _mappings
variable.
You can find below the possible signature of such methods:
public static bool TryGetMimeType(string? fileName, [NotNullWhen(true)] out string? mimeType);
public static string GetMimeType(string filename);
Both are good ideas. When I find time I'll implement, or you're welcome to submit a PR in the interim.
GetMimeType
exists already so it would be refactored to accept either an extension or a filename and check both.
TryGetMimeType
is obviously new and should support the same filename/extension semantics of GetMimeType
without duplicating any code (GetMimeType
can use TryGetMimeType
internally).