mirror of
https://github.com/ivanch/tcc.git
synced 2025-09-13 16:01:50 +00:00
adicionando pasta para ASP.NET
This commit is contained in:
68
ASP.NET/Controllers/ImageController.cs
Normal file
68
ASP.NET/Controllers/ImageController.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TCC.Services;
|
||||
|
||||
namespace TCC.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("image")]
|
||||
public class ImageController : ControllerBase
|
||||
{
|
||||
private ImageService ImageService { get; set; }
|
||||
public byte[] ImageData { get; set; }
|
||||
|
||||
public ImageController(ImageService imageService)
|
||||
{
|
||||
this.ImageService = imageService;
|
||||
}
|
||||
|
||||
[HttpPost("blur")]
|
||||
public async Task<IActionResult> BlurImage([FromQuery] int radius)
|
||||
{
|
||||
MemoryStream mstream = new MemoryStream();
|
||||
await HttpContext.Request.Body.CopyToAsync(mstream);
|
||||
mstream.Position = 0;
|
||||
|
||||
var result = ImageService.BoxBlurImage(mstream, radius);
|
||||
|
||||
var blurredImageStream = new MemoryStream();
|
||||
result.Write(blurredImageStream);
|
||||
blurredImageStream.Position = 0;
|
||||
|
||||
return File(blurredImageStream, "image/png");
|
||||
}
|
||||
|
||||
[HttpGet("load-image")]
|
||||
public async Task<IActionResult> GetSimpleImage()
|
||||
{
|
||||
var result = ImageService.GetSimpleImage();
|
||||
|
||||
var imageStream = new MemoryStream();
|
||||
result.Write(imageStream);
|
||||
imageStream.Position = 0;
|
||||
|
||||
return File(imageStream, "image/png");
|
||||
}
|
||||
|
||||
[HttpGet("load-big-image")]
|
||||
public async Task<IActionResult> GetBigImage()
|
||||
{
|
||||
var result = ImageService.GetBigImage();
|
||||
|
||||
var imageStream = new MemoryStream();
|
||||
result.Write(imageStream);
|
||||
imageStream.Position = 0;
|
||||
|
||||
return File(imageStream, "image/png");
|
||||
}
|
||||
|
||||
[HttpPost("save-big-image")]
|
||||
public async Task<IActionResult> SaveBigImage()
|
||||
{
|
||||
MemoryStream mstream = new MemoryStream();
|
||||
await HttpContext.Request.Body.CopyToAsync(mstream);
|
||||
mstream.Position = 0;
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
17
ASP.NET/Controllers/StatusController.cs
Normal file
17
ASP.NET/Controllers/StatusController.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace TCC.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("status")]
|
||||
public class StatusController : ControllerBase
|
||||
{
|
||||
public StatusController() { }
|
||||
|
||||
[HttpGet("ok")]
|
||||
public async Task<IActionResult> ReturnOk()
|
||||
{
|
||||
return Ok(new { status = 200 });
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user