Skip to content

Instantly share code, notes, and snippets.

@fardeen9983
Created March 31, 2022 12:05
Show Gist options
  • Save fardeen9983/bcec924c336d05c10afbc3c47bd76898 to your computer and use it in GitHub Desktop.
Save fardeen9983/bcec924c336d05c10afbc3c47bd76898 to your computer and use it in GitHub Desktop.
Expose FileUploadService
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