diff options
| author | Bond-009 <bond.009@outlook.com> | 2021-09-25 19:21:37 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-25 19:21:37 +0200 |
| commit | 2ee3e9e00f62ff8b0139f1273d7666d0f6c549a4 (patch) | |
| tree | 354f808d6687abcd3b5f862c0cb8c9e4fd754966 /MediaBrowser.Model/Net/MimeTypes.cs | |
| parent | d81c9a7a8cbab8967bfc66086c6f0f80bf7fc0c2 (diff) | |
| parent | 4643fd5dcbc6d1a4fbe973efc68d92ca71e3ab3b (diff) | |
Merge pull request #6590 from jellyfin/dotnet6
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..748170a0e 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">The default 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) |
