'Omit region from S3 pre-signed URL in aws-sdk-go-v2
Recently I migrated a code base from aws-sdk-go v1 to v2. But I noticed a difference that it seems isn't described on the migration guide, the pre-signed URL generated between v1 and v2 has changed:
- v1:
https://s3.amazonaws.com/<bucket>/<path> - v2:
https://s3.<region>.amazonaws.com/<bucket>/<path>
After some research, I found another Slack thread mentioning that v2 now uses sig4 which includes the region into the URL (here).
My problem is that I need to use the old hostname version without the region because of a legacy code that depends on s3.amazonaws.com hostname matching. So, I was hoping if there is any way to omit the region addition into the pre-signed URL in aws-sdk-go-v2.
Here is the code I am using to generate the S3 pre-signed URL:
input := &s3.GetObjectInput{
Bucket: aws.String(bucket),
Key: aws.String(key),
}
psClient := s3.NewPresignClient(c.s3Client, s3.WithPresignExpires(expires))
res, _ := psClient.PresignGetObject(ctx, input)
res.URL
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
