Last active
April 13, 2022 12:04
-
-
Save fardeen9983/9cd5653ee25743c1914041d58329b7e5 to your computer and use it in GitHub Desktop.
Updated Pre-signed URL method
This file contains hidden or 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
public async Task<string> GetS3ObjectPresignedUrl(IFormFile file) | |
{ | |
try | |
{ | |
var key = Path.GetRandomFileName() + Guid.NewGuid().ToString() + Path.GetExtension(file.FileName).ToLowerInvariant(); | |
if (await UploadFileToS3(file, key)) | |
{ | |
var getUrlRequest = new GetPreSignedUrlRequest | |
{ | |
BucketName = BucketName, | |
Key = key, | |
Expires = DateTime.UtcNow.AddHours(ExpirationDurationInHours), | |
}; | |
// New Change | |
await _notificationService.SendUploadNotification("hello"); | |
return _client.GetPreSignedURL(getUrlRequest); | |
} | |
return null; | |
} | |
catch (Exception) | |
{ | |
throw; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment