37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Diagnostics;
|
|
|
|
namespace Lux.API.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class ImageController : ControllerBase
|
|
{
|
|
public ImageController(ILogger<ImageController> logger)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
/// <summary>
|
|
/// Chiamata GET: riceve Json in formato JwdDto, restituisce svg file
|
|
/// GET: api/Jwd/svg/00000000-0000-0000-0000-000000000000
|
|
/// </summary>
|
|
/// <param name="id">id univoco img</param>
|
|
/// <returns></returns>
|
|
[HttpGet("svg/{id}")]
|
|
public async Task<IActionResult> svgFileGet(string id)
|
|
{
|
|
Stopwatch sw = new Stopwatch();
|
|
sw.Start();
|
|
string filePath = Path.Combine("DemoImg", "AntaDoppia.svg");
|
|
var svgContent = await System.IO.File.ReadAllTextAsync(filePath);
|
|
var bytes = System.Text.Encoding.UTF8.GetBytes(svgContent);
|
|
sw.Stop();
|
|
_logger.LogInformation($"svgString | {sw.Elapsed.TotalMilliseconds:N3} ms");
|
|
return File(bytes, "image/svg+xml");
|
|
}
|
|
|
|
private readonly ILogger<ImageController> _logger;
|
|
}
|
|
}
|