mudanças

This commit is contained in:
José Henrique Ivanchechen 2023-08-29 16:20:40 -03:00
parent 150ec0e1d7
commit 2085b7d89b
4 changed files with 8 additions and 21 deletions

View File

@ -34,25 +34,13 @@ namespace TCC.Controllers
[HttpGet("load-image")] [HttpGet("load-image")]
public async Task<IActionResult> GetSimpleImage() public async Task<IActionResult> GetSimpleImage()
{ {
var result = ImageService.GetSimpleImage(); return File(ImageService.GetSimpleImage(), "image/png");
var imageStream = new MemoryStream();
result.Write(imageStream);
imageStream.Position = 0;
return File(imageStream, "image/png");
} }
[HttpGet("load-big-image")] [HttpGet("load-big-image")]
public async Task<IActionResult> GetBigImage() public async Task<IActionResult> GetBigImage()
{ {
var result = ImageService.GetBigImage(); return File(ImageService.GetBigImage(), "image/png");
var imageStream = new MemoryStream();
result.Write(imageStream);
imageStream.Position = 0;
return File(imageStream, "image/png");
} }
[HttpPost("save-big-image")] [HttpPost("save-big-image")]

View File

@ -4,13 +4,13 @@ namespace tcc_app
{ {
public static class ImageHelper public static class ImageHelper
{ {
public static MagickImage SimpleImage; public static byte[] SimpleImage;
public static MagickImage BigImage; public static byte[] BigImage;
static ImageHelper() static ImageHelper()
{ {
SimpleImage = new MagickImage("simpleimage.png"); SimpleImage = File.ReadAllBytes("static/simpleimage.png");
BigImage = new MagickImage("bigimage.png"); BigImage = File.ReadAllBytes("static/bigimage.png");
} }
} }
} }

View File

@ -19,7 +19,6 @@ namespace TCC
options.Limits.MaxRequestBodySize = int.MaxValue; // if don't set default value is: 30 MB options.Limits.MaxRequestBodySize = int.MaxValue; // if don't set default value is: 30 MB
}); });
var app = builder.Build(); var app = builder.Build();
app.UseStaticFiles(new StaticFileOptions app.UseStaticFiles(new StaticFileOptions

View File

@ -62,12 +62,12 @@ namespace TCC.Services
file.Close(); file.Close();
} }
public MagickImage GetSimpleImage() public byte[] GetSimpleImage()
{ {
return ImageHelper.SimpleImage; return ImageHelper.SimpleImage;
} }
public MagickImage GetBigImage() public byte[] GetBigImage()
{ {
return ImageHelper.BigImage; return ImageHelper.BigImage;
} }