AttachmentController.cs 928 B

123456789101112131415161718192021222324252627282930313233343536
  1. using Microsoft.AspNetCore.Authorization;
  2. using Microsoft.AspNetCore.Http;
  3. using Microsoft.AspNetCore.Mvc;
  4. using MTWorkHR.Application.Filters;
  5. using MTWorkHR.Application.Models;
  6. using MTWorkHR.Application.Services;
  7. using MTWorkHR.Application.Services.Interfaces;
  8. namespace MTWorkHR.API.Controllers
  9. {
  10. [Route("api/[controller]")]
  11. [ApiController]
  12. [AppAuthorize]
  13. public class AttachmentController : ControllerBase
  14. {
  15. private readonly IFileService _fileService;
  16. public AttachmentController(IFileService fileService)
  17. {
  18. _fileService = fileService;
  19. }
  20. [HttpPost("Upload")]
  21. [ProducesResponseType(StatusCodes.Status200OK)]
  22. [Consumes("multipart/form-data")]
  23. public async Task<ActionResult<AttachmentResponseDto>> Upload(IFormFile input)
  24. {
  25. return Ok( await _fileService.UploadFile(input));
  26. }
  27. }
  28. }