- Initiate the node project npm init
- Create app.js
- Write console logs and run
๐
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; | |
} |
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
/// <summary> | |
/// Generates a presigned URL of the file if it is successfully uploaded to S3 | |
/// </summary> | |
/// <param name="file">File to be Uploaded</param> | |
/// <returns></returns> | |
public async Task<string> GetS3ObjectPresignedUrl(IFormFile file) | |
{ | |
try | |
{ | |
var key = Path.GetRandomFileName() + Guid.NewGuid().ToString() + Path.GetExtension(file.FileName).ToLowerInvariant(); |
NewerOlder