2023-03-04 19:52:21 +00:00
|
|
|
using Microsoft.AspNetCore.Cors;
|
2022-01-25 23:39:51 +00:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using VoidCat.Model;
|
2022-02-16 16:33:00 +00:00
|
|
|
using VoidCat.Services.Abstractions;
|
2022-07-25 17:59:32 +00:00
|
|
|
using VoidCat.Services.Files;
|
2022-01-25 23:39:51 +00:00
|
|
|
|
|
|
|
namespace VoidCat.Controllers;
|
|
|
|
|
|
|
|
[Route("d")]
|
2023-11-20 15:22:12 +00:00
|
|
|
public class DownloadController : BaseDownloadController
|
2022-01-25 23:39:51 +00:00
|
|
|
{
|
2022-09-06 21:32:22 +00:00
|
|
|
public DownloadController(FileStoreFactory storage, ILogger<DownloadController> logger, FileInfoManager fileInfo,
|
2023-05-30 10:24:13 +00:00
|
|
|
IPaymentOrderStore paymentOrderStore, VoidSettings settings, IPaymentFactory paymentFactory)
|
2023-11-20 15:22:12 +00:00
|
|
|
: base(settings, fileInfo, paymentOrderStore, paymentFactory, logger, storage)
|
2022-01-25 23:39:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-12-21 23:21:19 +00:00
|
|
|
[HttpHead]
|
2022-02-08 23:52:01 +00:00
|
|
|
[HttpOptions]
|
|
|
|
[Route("{id}")]
|
2023-03-04 19:52:21 +00:00
|
|
|
[EnableCors("*")]
|
2022-02-08 23:52:01 +00:00
|
|
|
public Task DownloadFileOptions([FromRoute] string id)
|
|
|
|
{
|
|
|
|
var gid = id.FromBase58Guid();
|
|
|
|
return SetupDownload(gid);
|
|
|
|
}
|
2022-02-08 23:56:35 +00:00
|
|
|
|
2022-03-08 13:47:42 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Download a specific file by Id
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id"></param>
|
2022-01-28 00:18:27 +00:00
|
|
|
[ResponseCache(Location = ResponseCacheLocation.Any, Duration = 86400)]
|
2022-01-25 23:39:51 +00:00
|
|
|
[HttpGet]
|
|
|
|
[Route("{id}")]
|
2023-03-04 19:52:21 +00:00
|
|
|
[EnableCors("*")]
|
2022-01-25 23:39:51 +00:00
|
|
|
public async Task DownloadFile([FromRoute] string id)
|
|
|
|
{
|
|
|
|
var gid = id.FromBase58Guid();
|
2022-02-17 15:52:49 +00:00
|
|
|
var voidFile = await SetupDownload(gid);
|
2022-02-21 09:39:59 +00:00
|
|
|
if (voidFile == default) return;
|
2022-02-08 23:52:01 +00:00
|
|
|
|
2023-11-20 15:22:12 +00:00
|
|
|
await SendResponse(id, voidFile);
|
2022-01-25 23:39:51 +00:00
|
|
|
}
|
2023-03-04 16:44:13 +00:00
|
|
|
}
|