Browse Source

Fix return content type

crobibero 5 năm trước cách đây
mục cha
commit
51d54a8ca4

+ 7 - 7
Jellyfin.Api/Controllers/VideoAttachmentsController.cs

@@ -1,11 +1,13 @@
 #nullable enable
 #nullable enable
 
 
 using System;
 using System;
+using System.Net.Mime;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Common.Extensions;
 using MediaBrowser.Common.Extensions;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.MediaEncoding;
 using MediaBrowser.Controller.MediaEncoding;
+using MediaBrowser.Model.Net;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc;
@@ -17,7 +19,7 @@ namespace Jellyfin.Api.Controllers
     /// </summary>
     /// </summary>
     [Route("Videos")]
     [Route("Videos")]
     [Authorize]
     [Authorize]
-    public class VideoAttachmentsController : Controller
+    public class VideoAttachmentsController : BaseJellyfinApiController
     {
     {
         private readonly ILibraryManager _libraryManager;
         private readonly ILibraryManager _libraryManager;
         private readonly IAttachmentExtractor _attachmentExtractor;
         private readonly IAttachmentExtractor _attachmentExtractor;
@@ -45,7 +47,7 @@ namespace Jellyfin.Api.Controllers
         /// <response code="404">Video or attachment not found.</response>
         /// <response code="404">Video or attachment not found.</response>
         /// <returns>An <see cref="FileStreamResult"/> containing the attachment stream on success, or a <see cref="NotFoundResult"/> if the attachment could not be found.</returns>
         /// <returns>An <see cref="FileStreamResult"/> containing the attachment stream on success, or a <see cref="NotFoundResult"/> if the attachment could not be found.</returns>
         [HttpGet("{VideoID}/{MediaSourceID}/Attachments/{Index}")]
         [HttpGet("{VideoID}/{MediaSourceID}/Attachments/{Index}")]
-        [Produces("application/octet-stream")]
+        [Produces(MediaTypeNames.Application.Octet)]
         [ProducesResponseType(StatusCodes.Status200OK)]
         [ProducesResponseType(StatusCodes.Status200OK)]
         [ProducesResponseType(StatusCodes.Status404NotFound)]
         [ProducesResponseType(StatusCodes.Status404NotFound)]
         public async Task<ActionResult<FileStreamResult>> GetAttachment(
         public async Task<ActionResult<FileStreamResult>> GetAttachment(
@@ -68,11 +70,9 @@ namespace Jellyfin.Api.Controllers
                         CancellationToken.None)
                         CancellationToken.None)
                     .ConfigureAwait(false);
                     .ConfigureAwait(false);
 
 
-                var contentType = "application/octet-stream";
-                if (string.IsNullOrWhiteSpace(attachment.MimeType))
-                {
-                    contentType = attachment.MimeType;
-                }
+                var contentType = string.IsNullOrWhiteSpace(attachment.MimeType)
+                    ? MediaTypeNames.Application.Octet
+                    : attachment.MimeType;
 
 
                 return new FileStreamResult(stream, contentType);
                 return new FileStreamResult(stream, contentType);
             }
             }