Created
June 11, 2024 06:41
-
-
Save bagasdisini/7297d7892eb074969b9c12f94ed955c3 to your computer and use it in GitHub Desktop.
Get presigned url AWS S3 (private file)
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
func GetPresignedUrl(file string) (string, error) { | |
req, _ := S3Client.GetObjectRequest(&s3.GetObjectInput{ | |
Bucket: aws.String(config.S3.Bucket), | |
Key: aws.String(file), | |
ResponseContentDisposition: aws.String("attachment; filename=\"" + filepath.Base(file) + "\""), // to make sure the file is automatically downloaded | |
}) | |
return req.Presign(config.S3.PresignDuration) // time.Duration | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment