Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PresignPostObject adding condition itself #2992

Closed
2 of 3 tasks
okankaraduman opened this issue Jan 30, 2025 · 2 comments
Closed
2 of 3 tasks

PresignPostObject adding condition itself #2992

okankaraduman opened this issue Jan 30, 2025 · 2 comments
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@okankaraduman
Copy link

Acknowledgements

Describe the bug

I am using PresignPostObject method of the PresignClient

and I am setting the conditions as
Conditions: []interface{}{
[]string{"starts-with", "$key", key},
[]string{"eq", "$Content-Type", "application/pdf"},
},
with the key being statement_503383/

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Allow the upload the file with the prefix.

Current Behavior

but when I try to upload the file using the payload that PresignPostObject returns and with the key statement_503383/testfile.pdf

api itself gives:

Invalid according to Policy: Policy Condition failed: ["eq", "$key", "statement_50333804/"]
when key is statement_503383/testfile.pdf

I did not set that policy and I couldn't figure out where it is coming from.

Reproduction Steps

input := &s3.PutObjectInput{
Bucket: &bucket,
Key: &key,
}

fmt.Printf("Conditions: %+v\n", options.Conditions)

response, err := a.client.PresignPostObject(ctx, input, func(opts *s3.PresignPostOptions) {
	fmt.Printf("PresignPostObject options before modification: %+v\n", opts)

	opts.Expires = options.Expires
	opts.Conditions = options.Conditions
})
if err != nil {
	return nil, err
}

postRequest := PreSignedPostRequest{
	URL:    response.URL,
	Fields: response.Values,
}

Possible Solution

No response

Additional Information/Context

No response

AWS Go SDK V2 Module Versions Used

github.com/aws/aws-sdk-go-v2 v1.34.0
github.com/aws/aws-sdk-go-v2/service/s3 v1.71.0
github.com/aws/aws-sdk-go-v2/service/sns v1.33.7
github.com/aws/aws-sdk-go-v2/service/sqs v1.37.2

Compiler and Version used

go version go1.23.0 darwin/arm64

Operating System and version

macOS

@okankaraduman okankaraduman added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 30, 2025
@okankaraduman okankaraduman changed the title (short issue description) PresignPostObject adding condition itself Jan 30, 2025
@okankaraduman
Copy link
Author

This is resolved one apparently I do have to send interface :

Conditions: []interface{}{
[]interface{}{"starts-with", "$key", "statement_50333804/"},
},

this is not working:
Conditions: []interface{}{
[]string["starts-with", "$key", "statement_50333804/"],
},
and it was adding both starts-with and eq conditions to the policy:

["starts-with","$key","statement_50333804/"], {key, statement_50333804/}]

Copy link

github-actions bot commented Feb 4, 2025

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant