Skip to content

Instantly share code, notes, and snippets.

@fardeen9983
Last active April 13, 2022 12:04
Show Gist options
  • Save fardeen9983/9cd5653ee25743c1914041d58329b7e5 to your computer and use it in GitHub Desktop.
Save fardeen9983/9cd5653ee25743c1914041d58329b7e5 to your computer and use it in GitHub Desktop.
Updated Pre-signed URL method
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