Clean api return types

This commit is contained in:
crobibero 2020-09-02 15:06:13 -06:00
parent a698dab66f
commit 932c4d25a4
2 changed files with 9 additions and 9 deletions

View file

@ -189,7 +189,7 @@ namespace Jellyfin.Api.Controllers
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesImageFile] [ProducesImageFile]
public ActionResult<FileResult> GetIconId([FromRoute] string serverId, [FromRoute] string fileName) public ActionResult GetIconId([FromRoute] string serverId, [FromRoute] string fileName)
{ {
return GetIconInternal(fileName); return GetIconInternal(fileName);
} }
@ -201,12 +201,12 @@ namespace Jellyfin.Api.Controllers
/// <returns>Icon stream.</returns> /// <returns>Icon stream.</returns>
[HttpGet("icons/{fileName}")] [HttpGet("icons/{fileName}")]
[ProducesImageFile] [ProducesImageFile]
public ActionResult<FileResult> GetIcon([FromRoute] string fileName) public ActionResult GetIcon([FromRoute] string fileName)
{ {
return GetIconInternal(fileName); return GetIconInternal(fileName);
} }
private ActionResult<FileResult> GetIconInternal(string fileName) private ActionResult GetIconInternal(string fileName)
{ {
var icon = _dlnaManager.GetIcon(fileName); var icon = _dlnaManager.GetIcon(fileName);
if (icon == null) if (icon == null)

View file

@ -65,7 +65,7 @@ namespace Jellyfin.Api.Controllers
[Produces(MediaTypeNames.Application.Octet)] [Produces(MediaTypeNames.Application.Octet)]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult<FileStreamResult> GetGeneralImage([FromRoute, Required] string? name, [FromRoute, Required] string? type) public ActionResult GetGeneralImage([FromRoute, Required] string? name, [FromRoute, Required] string? type)
{ {
var filename = string.Equals(type, "primary", StringComparison.OrdinalIgnoreCase) var filename = string.Equals(type, "primary", StringComparison.OrdinalIgnoreCase)
? "folder" ? "folder"
@ -110,7 +110,7 @@ namespace Jellyfin.Api.Controllers
[Produces(MediaTypeNames.Application.Octet)] [Produces(MediaTypeNames.Application.Octet)]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult<FileStreamResult> GetRatingImage( public ActionResult GetRatingImage(
[FromRoute, Required] string? theme, [FromRoute, Required] string? theme,
[FromRoute, Required] string? name) [FromRoute, Required] string? name)
{ {
@ -143,7 +143,7 @@ namespace Jellyfin.Api.Controllers
[Produces(MediaTypeNames.Application.Octet)] [Produces(MediaTypeNames.Application.Octet)]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult<FileStreamResult> GetMediaInfoImage( public ActionResult GetMediaInfoImage(
[FromRoute, Required] string? theme, [FromRoute, Required] string? theme,
[FromRoute, Required] string? name) [FromRoute, Required] string? name)
{ {
@ -157,7 +157,7 @@ namespace Jellyfin.Api.Controllers
/// <param name="theme">Theme to search.</param> /// <param name="theme">Theme to search.</param>
/// <param name="name">File name to search for.</param> /// <param name="name">File name to search for.</param>
/// <returns>A <see cref="FileStreamResult"/> containing the image contents on success, or a <see cref="NotFoundResult"/> if the image could not be found.</returns> /// <returns>A <see cref="FileStreamResult"/> containing the image contents on success, or a <see cref="NotFoundResult"/> if the image could not be found.</returns>
private ActionResult<FileStreamResult> GetImageFile(string basePath, string? theme, string? name) private ActionResult GetImageFile(string basePath, string? theme, string? name)
{ {
var themeFolder = Path.Combine(basePath, theme); var themeFolder = Path.Combine(basePath, theme);
if (Directory.Exists(themeFolder)) if (Directory.Exists(themeFolder))
@ -168,7 +168,7 @@ namespace Jellyfin.Api.Controllers
if (!string.IsNullOrEmpty(path) && System.IO.File.Exists(path)) if (!string.IsNullOrEmpty(path) && System.IO.File.Exists(path))
{ {
var contentType = MimeTypes.GetMimeType(path); var contentType = MimeTypes.GetMimeType(path);
return File(System.IO.File.OpenRead(path), contentType); return PhysicalFile(path, contentType);
} }
} }
@ -181,7 +181,7 @@ namespace Jellyfin.Api.Controllers
if (!string.IsNullOrEmpty(path) && System.IO.File.Exists(path)) if (!string.IsNullOrEmpty(path) && System.IO.File.Exists(path))
{ {
var contentType = MimeTypes.GetMimeType(path); var contentType = MimeTypes.GetMimeType(path);
return File(System.IO.File.OpenRead(path), contentType); return PhysicalFile(path, contentType);
} }
} }