tcc/ASP.NET/Controllers/ImageController.cs

44 lines
1.1 KiB
C#
Raw Normal View History

2023-08-16 18:58:01 +00:00
using Microsoft.AspNetCore.Mvc;
using TCC.Services;
2023-08-16 18:40:27 +00:00
2023-08-16 18:58:01 +00:00
namespace TCC.Controllers
2023-08-16 18:40:27 +00:00
{
[ApiController]
2023-08-20 20:21:58 +00:00
[Route("image")]
2023-08-16 18:40:27 +00:00
public class ImageController : ControllerBase
{
2023-08-16 18:58:01 +00:00
private ImageService ImageService { get; set; }
2023-08-18 18:14:53 +00:00
public byte[] ImageData { get; set; }
2023-08-16 18:58:01 +00:00
public ImageController(ImageService imageService)
{
this.ImageService = imageService;
}
2023-09-11 02:14:21 +00:00
[HttpGet("load-small-image")]
2023-08-20 20:21:58 +00:00
public async Task<IActionResult> GetSimpleImage()
{
2023-09-11 02:14:21 +00:00
return File(ImageService.GetSimpleImage(), "image/png");
2023-08-20 20:21:58 +00:00
}
[HttpGet("load-big-image")]
public async Task<IActionResult> GetBigImage()
{
2023-09-11 02:14:21 +00:00
return File(ImageService.GetBigImage(), "image/png");
2023-08-20 20:21:58 +00:00
}
[HttpPost("save-big-image")]
public async Task<IActionResult> SaveBigImage()
{
MemoryStream mstream = new MemoryStream();
await HttpContext.Request.Body.CopyToAsync(mstream);
mstream.Position = 0;
2023-09-24 13:56:01 +00:00
ImageService.SaveImage(mstream);
2023-09-11 02:14:21 +00:00
mstream.Close();
2023-08-20 20:21:58 +00:00
return Ok();
}
2023-08-16 18:40:27 +00:00
}
}