Skip to content

Cannot create presign url for PUT with metadata in SDKv2, whereas it was working for SDKv1 #2702

Closed
@Harital

Description

Pre-Migration Checklist

Go Version Used

1.22

Describe the Migration Issue

In AWS SDK v1 there could be constructed presign urls for put objects with the metadata embedded in it. It was easy and transparent for the users of these url's. A simple PUT to the presign url would suffice to get an object uploaded in an S3 with the proper metadata.

In AWS SDK v2 this feature is broken. The client needs to send a header with the metadata alongside the presign url in order to work. Otherwise, a 403 error is returned. This makes no sense, as the user of the presign url's does not have (or at least, should not have) any knowledge of the S3 internals.

Code Comparison

v1: metadata was added to the query

req, _ := s3ClientV1.PutObjectRequest(&s3sdkv1aws.PutObjectInput{
	Bucket: aws.String("myBucket"),
	Key:    aws.String("myFilePath"),
})

// Add user metadata.
query := req.HTTPRequest.URL.Query()
query.Add("x-amz-meta-whatever", "metadataValue")
req.HTTPRequest.URL.RawQuery = query.Encode()

v2: new way of adding metadata

request, err := s3Clientv2.PresignPutObject(ctx, &s3.PutObjectInput{
	Bucket:      aws.String("myBucket"),
	Key:         aws.String("myFilePath"),
	Metadata:    map[string]string{"whatever": "metadataValue"},
}, func(opts *s3.PresignOptions) {
	opts.Expires = clock.Duration(8 * int64(time.Hour))
})

Observed Differences/Errors

When making a PUT to a presign url generated with v1, the object was properly uploaded with its metadata. When doing so with v2 a 403 error is returned, unless the metadata is passed as a header alongside the presign url.

Additional Context

This issue has been causing several prlblems several times in several languages, but it seems not to be any clear solution.
aws/aws-sdk-go#1467
#1474
aws/aws-sdk-java-v2#5060
aws/aws-sdk-java-v2#2200

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

p2This is a standard priority issuequeuedThis issues is on the AWS team's backlogv1-v2-inconsistencyv1-v2-inconsistency Behavior has changed from v1 to v2, or feature is missing altogetherworkaround-available

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions