mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-10-31 10:37:22 -04:00 
			
		
		
		
	Use MediaTypeNames where possible (#13440)
This commit is contained in:
		
							parent
							
								
									7e9ce78849
								
							
						
					
					
						commit
						7684986fa1
					
				| @ -7,6 +7,7 @@ using System.Collections.Generic; | |||||||
| using System.Globalization; | using System.Globalization; | ||||||
| using System.IO; | using System.IO; | ||||||
| using System.Linq; | using System.Linq; | ||||||
|  | using System.Net.Mime; | ||||||
| using System.Threading; | using System.Threading; | ||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
| using MediaBrowser.Common.Configuration; | using MediaBrowser.Common.Configuration; | ||||||
| @ -116,9 +117,9 @@ namespace Emby.Server.Implementations.Images | |||||||
| 
 | 
 | ||||||
|             var mimeType = MimeTypes.GetMimeType(outputPath); |             var mimeType = MimeTypes.GetMimeType(outputPath); | ||||||
| 
 | 
 | ||||||
|             if (string.Equals(mimeType, "application/octet-stream", StringComparison.OrdinalIgnoreCase)) |             if (string.Equals(mimeType, MediaTypeNames.Application.Octet, StringComparison.OrdinalIgnoreCase)) | ||||||
|             { |             { | ||||||
|                 mimeType = "image/png"; |                 mimeType = MediaTypeNames.Image.Png; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             await ProviderManager.SaveImage(item, outputPath, mimeType, imageType, null, false, cancellationToken).ConfigureAwait(false); |             await ProviderManager.SaveImage(item, outputPath, mimeType, imageType, null, false, cancellationToken).ConfigureAwait(false); | ||||||
|  | |||||||
| @ -17,12 +17,12 @@ public static class ImageFormatExtensions | |||||||
|     public static string GetMimeType(this ImageFormat format) |     public static string GetMimeType(this ImageFormat format) | ||||||
|         => format switch |         => format switch | ||||||
|         { |         { | ||||||
|             ImageFormat.Bmp => "image/bmp", |             ImageFormat.Bmp => MediaTypeNames.Image.Bmp, | ||||||
|             ImageFormat.Gif => MediaTypeNames.Image.Gif, |             ImageFormat.Gif => MediaTypeNames.Image.Gif, | ||||||
|             ImageFormat.Jpg => MediaTypeNames.Image.Jpeg, |             ImageFormat.Jpg => MediaTypeNames.Image.Jpeg, | ||||||
|             ImageFormat.Png => "image/png", |             ImageFormat.Png => MediaTypeNames.Image.Png, | ||||||
|             ImageFormat.Webp => "image/webp", |             ImageFormat.Webp => MediaTypeNames.Image.Webp, | ||||||
|             ImageFormat.Svg => "image/svg+xml", |             ImageFormat.Svg => MediaTypeNames.Image.Svg, | ||||||
|             _ => throw new InvalidEnumArgumentException(nameof(format), (int)format, typeof(ImageFormat)) |             _ => throw new InvalidEnumArgumentException(nameof(format), (int)format, typeof(ImageFormat)) | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -6,6 +6,7 @@ using System.Collections.Generic; | |||||||
| using System.Diagnostics.CodeAnalysis; | using System.Diagnostics.CodeAnalysis; | ||||||
| using System.IO; | using System.IO; | ||||||
| using System.Linq; | using System.Linq; | ||||||
|  | using System.Net.Mime; | ||||||
| using Jellyfin.Extensions; | using Jellyfin.Extensions; | ||||||
| 
 | 
 | ||||||
| namespace MediaBrowser.Model.Net | namespace MediaBrowser.Model.Net | ||||||
| @ -144,7 +145,7 @@ namespace MediaBrowser.Model.Net | |||||||
|             new("video/x-matroska", ".mkv"), |             new("video/x-matroska", ".mkv"), | ||||||
|         }.ToFrozenDictionary(pair => pair.Key, pair => pair.Value, StringComparer.OrdinalIgnoreCase); |         }.ToFrozenDictionary(pair => pair.Key, pair => pair.Value, StringComparer.OrdinalIgnoreCase); | ||||||
| 
 | 
 | ||||||
|         public static string GetMimeType(string path) => GetMimeType(path, "application/octet-stream"); |         public static string GetMimeType(string path) => GetMimeType(path, MediaTypeNames.Application.Octet); | ||||||
| 
 | 
 | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets the type of the MIME. |         /// Gets the type of the MIME. | ||||||
|  | |||||||
| @ -5,6 +5,7 @@ using System.IO; | |||||||
| using System.Linq; | using System.Linq; | ||||||
| using System.Net; | using System.Net; | ||||||
| using System.Net.Http; | using System.Net.Http; | ||||||
|  | using System.Net.Mime; | ||||||
| using System.Text; | using System.Text; | ||||||
| using System.Text.RegularExpressions; | using System.Text.RegularExpressions; | ||||||
| using System.Threading; | using System.Threading; | ||||||
| @ -391,7 +392,7 @@ namespace Jellyfin.Providers.Tests.Manager | |||||||
|                 { |                 { | ||||||
|                     ReasonPhrase = url, |                     ReasonPhrase = url, | ||||||
|                     StatusCode = HttpStatusCode.OK, |                     StatusCode = HttpStatusCode.OK, | ||||||
|                     Content = new StringContent(Content, Encoding.UTF8, "image/jpeg") |                     Content = new StringContent(Content, Encoding.UTF8, MediaTypeNames.Image.Jpeg) | ||||||
|                 }); |                 }); | ||||||
| 
 | 
 | ||||||
|             var refreshOptions = fullRefresh |             var refreshOptions = fullRefresh | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user