diff options
| author | Bond_009 <bond.009@outlook.com> | 2021-02-14 15:11:46 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2021-09-24 20:15:46 +0200 |
| commit | 13fbfe6091e61450aedc07bc78c96bf4c414bc65 (patch) | |
| tree | 10f5ac5542f30568a3b4b6e84a05768bd0e93eb7 /MediaBrowser.Model/Net/MimeTypes.cs | |
| parent | 1ebd3c9ac33ab99813307728ad6efbf53a667d4e (diff) | |
Target net6.0
Diffstat (limited to 'MediaBrowser.Model/Net/MimeTypes.cs')
| -rw-r--r-- | MediaBrowser.Model/Net/MimeTypes.cs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/MediaBrowser.Model/Net/MimeTypes.cs b/MediaBrowser.Model/Net/MimeTypes.cs index 7b3c17c85..1d9150f02 100644 --- a/MediaBrowser.Model/Net/MimeTypes.cs +++ b/MediaBrowser.Model/Net/MimeTypes.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using Jellyfin.Extensions; @@ -164,15 +165,16 @@ namespace MediaBrowser.Model.Net return dict; } - public static string? GetMimeType(string path) => GetMimeType(path, true); + public static string GetMimeType(string path) => GetMimeType(path, "application/octet-stream"); /// <summary> /// Gets the type of the MIME. /// </summary> /// <param name="filename">The filename to find the MIME type of.</param> - /// <param name="enableStreamDefault">Whether of not to return a default value if no fitting MIME type is found.</param> - /// <returns>The worrect MIME type for the given filename, or `null` if it wasn't found and <paramref name="enableStreamDefault"/> is false.</returns> - public static string? GetMimeType(string filename, bool enableStreamDefault) + /// <param name="defaultValue">Theefault value to return if no fitting MIME type is found.</param> + /// <returns>The correct MIME type for the given filename, or <paramref name="defaultValue"/> if it wasn't found.</returns> + [return: NotNullIfNotNullAttribute("defaultValue")] + public static string? GetMimeType(string filename, string? defaultValue = null) { if (filename.Length == 0) { @@ -211,7 +213,7 @@ namespace MediaBrowser.Model.Net return "application/octet-stream"; } - return enableStreamDefault ? "application/octet-stream" : null; + return defaultValue; } public static string? ToExtension(string mimeType) |
