using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; using WeatherForecast.Services; using DomainResults.Mvc; namespace WeatherForecast.Controllers; /// /// /// [AllowAnonymous] [Route("api/[controller]")] [ApiController] public class ImageController : ControllerBase { private readonly IImageService _imageService; /// /// /// /// public ImageController( IImageService imgeService ) { _imageService = imgeService; } /// /// /// /// /// /// /// /// [HttpGet("{siteId}/{width}x{height}/{imageId}")] public IActionResult Get([FromRoute] Guid siteId, [FromRoute] int width, [FromRoute] int height, [FromRoute] Guid imageId) { var (file, result) = _imageService.Get(siteId, width, height, imageId); if (!result.IsSuccess || file == null) return result.ToActionResult(); var stream = new MemoryStream(file.Bytes); return new FileStreamResult(stream, file.ContentType) { FileDownloadName = file.Name }; } }