2019-04-22 09:41:20 +02:00
|
|
|
using System.Threading.Tasks;
|
2019-05-24 08:44:23 +02:00
|
|
|
using BTCPayServer.Configuration;
|
2019-04-22 09:41:20 +02:00
|
|
|
using BTCPayServer.Storage.Services;
|
2019-05-24 08:44:23 +02:00
|
|
|
using BTCPayServer.Storage.Services.Providers.FileSystemStorage;
|
2019-04-22 09:41:20 +02:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
namespace BTCPayServer.Storage
|
|
|
|
{
|
|
|
|
[Route("Storage")]
|
2019-05-24 08:44:23 +02:00
|
|
|
public class StorageController : Controller
|
2019-04-22 09:41:20 +02:00
|
|
|
{
|
|
|
|
private readonly FileService _FileService;
|
2020-06-29 05:07:48 +02:00
|
|
|
private readonly string _dir;
|
2019-04-22 09:41:20 +02:00
|
|
|
|
2019-05-24 08:44:23 +02:00
|
|
|
public StorageController(FileService fileService, BTCPayServerOptions serverOptions)
|
2019-04-22 09:41:20 +02:00
|
|
|
{
|
|
|
|
_FileService = fileService;
|
2020-06-28 10:55:27 +02:00
|
|
|
_dir = FileSystemFileProviderService.GetTempStorageDir(serverOptions);
|
2019-04-22 09:41:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[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);
|
2019-04-22 09:41:20 +02:00
|
|
|
return new RedirectResult(url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|