2019-04-22 09:41:20 +02:00
|
|
|
using System.Threading.Tasks;
|
2022-03-02 18:28:12 +01:00
|
|
|
using BTCPayServer.Abstractions.Extensions;
|
2019-04-22 09:41:20 +02:00
|
|
|
using BTCPayServer.Storage.Services;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
namespace BTCPayServer.Storage
|
|
|
|
{
|
|
|
|
[Route("Storage")]
|
2022-01-07 04:32:00 +01:00
|
|
|
public class UIStorageController : Controller
|
2019-04-22 09:41:20 +02:00
|
|
|
{
|
|
|
|
private readonly FileService _FileService;
|
|
|
|
|
2022-01-07 04:32:00 +01:00
|
|
|
public UIStorageController(FileService fileService)
|
2019-04-22 09:41:20 +02:00
|
|
|
{
|
|
|
|
_FileService = fileService;
|
|
|
|
}
|
|
|
|
|
|
|
|
[HttpGet("{fileId}")]
|
|
|
|
public async Task<IActionResult> GetFile(string fileId)
|
|
|
|
{
|
2019-05-24 08:44:23 +02:00
|
|
|
var url = await _FileService.GetFileUrl(Request.GetAbsoluteRootUri(), fileId);
|
2022-05-02 02:43:55 +02:00
|
|
|
if (url is null)
|
|
|
|
return NotFound();
|
2019-04-22 09:41:20 +02:00
|
|
|
return new RedirectResult(url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|