Skip to content

Instantly share code, notes, and snippets.

@bagasdisini
Created June 11, 2024 06:41
Show Gist options
  • Save bagasdisini/7297d7892eb074969b9c12f94ed955c3 to your computer and use it in GitHub Desktop.
Save bagasdisini/7297d7892eb074969b9c12f94ed955c3 to your computer and use it in GitHub Desktop.
Get presigned url AWS S3 (private file)
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