Created
March 31, 2022 12:05
-
-
Save fardeen9983/bcec924c336d05c10afbc3c47bd76898 to your computer and use it in GitHub Desktop.
Expose FileUploadService
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace CodePanthers.AWS.S3.UploadService.Controllers | |
{ | |
[Route("Upload")] | |
public class UploadController : Controller | |
{ | |
private readonly IFileUploadService _fileUploadService; | |
public UploadController(IFileUploadService fileUploadService) | |
{ | |
_fileUploadService = fileUploadService; | |
} | |
[HttpPost] | |
public async Task<IActionResult> Index([FromForm] IFormFile file) | |
{ | |
var presignedUrl = await _fileUploadService.GetS3ObjectPresignedUrl(file); | |
if (presignedUrl != null) | |
return Ok(new { status = "Success", url = presignedUrl }); | |
else | |
return BadRequest(new { status = "Failed", message = "Something went wrong" }); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment