diff --git a/Jellyfin.Api/Controllers/Images/RemoteImageController.cs b/Jellyfin.Api/Controllers/Images/RemoteImageController.cs
index a0754ed4eb..665db561bf 100644
--- a/Jellyfin.Api/Controllers/Images/RemoteImageController.cs
+++ b/Jellyfin.Api/Controllers/Images/RemoteImageController.cs
@@ -1,6 +1,7 @@
#nullable enable
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
@@ -9,12 +10,12 @@ using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Providers;
+using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
@@ -25,7 +26,7 @@ namespace Jellyfin.Api.Controllers.Images
/// Remote Images Controller.
///
[Route("Images")]
- [Authenticated]
+ [Authorize]
public class RemoteImageController : BaseJellyfinApiController
{
private readonly IProviderManager _providerManager;
@@ -60,7 +61,9 @@ namespace Jellyfin.Api.Controllers.Images
/// Optional. The record index to start at. All items with a lower index will be dropped from the results.
/// Optional. The maximum number of records to return.
/// Optional. The image provider to use.
- /// Optinal. Include all languages.
+ /// Optional. Include all languages.
+ /// Remote Images returned.
+ /// Item not found.
/// Remote Image Result.
[HttpGet("{Id}/RemoteImages")]
[ProducesResponseType(StatusCodes.Status200OK)]
@@ -116,18 +119,20 @@ namespace Jellyfin.Api.Controllers.Images
}
result.Images = imageArray;
- return Ok(result);
+ return result;
}
///
/// Gets available remote image providers for an item.
///
/// Item Id.
- /// List of providers.
+ /// Returned remote image providers.
+ /// Item not found.
+ /// List of remote image providers.
[HttpGet("{Id}/RemoteImages/Providers")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
- public ActionResult GetRemoteImageProviders([FromRoute] string id)
+ public ActionResult> GetRemoteImageProviders([FromRoute] string id)
{
var item = _libraryManager.GetItemById(id);
if (item == null)
@@ -135,14 +140,15 @@ namespace Jellyfin.Api.Controllers.Images
return NotFound();
}
- var providers = _providerManager.GetRemoteImageProviderInfo(item);
- return Ok(providers);
+ return Ok(_providerManager.GetRemoteImageProviderInfo(item));
}
///
/// Gets a remote image.
///
/// The image url.
+ /// Remote image returned.
+ /// Remote image not found.
/// Image Stream.
[HttpGet("Remote")]
[Produces("application/octet-stream")]
@@ -154,7 +160,7 @@ namespace Jellyfin.Api.Controllers.Images
var pointerCachePath = GetFullCachePath(urlHash.ToString());
string? contentPath = null;
- bool hasFile = false;
+ var hasFile = false;
try
{
@@ -166,11 +172,11 @@ namespace Jellyfin.Api.Controllers.Images
}
catch (FileNotFoundException)
{
- // Means the file isn't cached yet
+ // The file isn't cached yet
}
catch (IOException)
{
- // Means the file isn't cached yet
+ // The file isn't cached yet
}
if (!hasFile)
@@ -194,7 +200,9 @@ namespace Jellyfin.Api.Controllers.Images
/// Item Id.
/// The image type.
/// The image url.
- /// Status.
+ /// Remote image downloaded.
+ /// Remote image not found.
+ /// Download status.
[HttpPost("{Id}/RemoteImages/Download")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
@@ -245,10 +253,10 @@ namespace Jellyfin.Api.Controllers.Images
var fullCachePath = GetFullCachePath(urlHash + "." + ext);
Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath));
- using (var stream = result.Content)
+ await using (var stream = result.Content)
{
- using var filestream = new FileStream(fullCachePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true);
- await stream.CopyToAsync(filestream).ConfigureAwait(false);
+ await using var fileStream = new FileStream(fullCachePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true);
+ await stream.CopyToAsync(fileStream).ConfigureAwait(false);
}
Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath));