43 lines
1.5 KiB
C#
43 lines
1.5 KiB
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Strata.Stratasphere.Biz.Mappings.Exports;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Strata.Stratasphere.Api.Controllers
|
|
{
|
|
[ApiController]
|
|
[ApiVersion("1.0")]
|
|
[Route("api/v{api-version:apiVersion}/[controller]")]
|
|
public class ExportController : ControllerBase
|
|
{
|
|
private readonly IExportJobService _exportJobService;
|
|
|
|
public ExportController(IExportJobService exportJobService)
|
|
{
|
|
_exportJobService = exportJobService;
|
|
}
|
|
|
|
[HttpGet("[action]")]
|
|
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
[ProducesDefaultResponseType]
|
|
public async Task<IActionResult> Download([FromQuery] string filename, CancellationToken cancellationToken)
|
|
{
|
|
var memoryStream = await _exportJobService.DownloadFile(filename, cancellationToken);
|
|
|
|
return new FileContentResult(memoryStream.ToArray(),
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
|
{
|
|
FileDownloadName = filename
|
|
};
|
|
}
|
|
|
|
[HttpGet("[action]")]
|
|
public async Task<IEnumerable<string>> GetExports(CancellationToken cancellationToken)
|
|
{
|
|
return await _exportJobService.GetExports(cancellationToken);
|
|
}
|
|
}
|
|
} |