33 lines
982 B
C#
33 lines
982 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using PdfMarker.Models;
|
|
using PdfMarker.Services;
|
|
|
|
namespace PdfMarker.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/ballooning")]
|
|
public class BallooningController : ControllerBase
|
|
{
|
|
private readonly BallooningService _ballooningService;
|
|
private readonly IWebHostEnvironment _env;
|
|
|
|
public BallooningController(BallooningService ballooningService, IWebHostEnvironment env)
|
|
{
|
|
_ballooningService = ballooningService;
|
|
_env = env;
|
|
}
|
|
|
|
[HttpPost("process")]
|
|
public async Task<ActionResult<AutoBalloonResult>> Process([FromBody] AutoBalloonRequest request)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(request.FileName))
|
|
return BadRequest("FileName is required");
|
|
|
|
var uploadsPath = Path.Combine(_env.WebRootPath, "uploads");
|
|
var fName = $"{uploadsPath}/{request.FileName}";
|
|
|
|
var result = await _ballooningService.GenerateAsync(fName);
|
|
|
|
return Ok(result);
|
|
}
|
|
} |