Poszukiwacz/Serwer/Serwer.Api/Controllers/ImageController.cs

38 lines
1023 B
C#
Raw Normal View History

2020-12-12 14:18:31 +01:00
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Serwer.Infrastructure.Services;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace Serwer.Api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ImageController : ControllerBase
{
private readonly IImageService _imageService;
public ImageController(IImageService imageService)
{
_imageService = imageService;
}
[HttpPost("Process")]
public async Task<IActionResult> Process(IFormFile image)
{
if(image == null)
{
return NotFound();
}
using (var memoryStream = new MemoryStream())
{
await image.CopyToAsync(memoryStream);
await _imageService.Process(image.Name, image.ContentType, memoryStream.ToArray());
}
return Ok();
}
}
}