Skip to content

Commit

Permalink
Fixed #2000 - Add support for "starts-with" in user-metadata post pol…
Browse files Browse the repository at this point in the history
…icy condition. (#2001)
  • Loading branch information
hsequeda authored Sep 19, 2024
1 parent b1f8dd0 commit 100ddb4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions post-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,25 @@ func (p *PostPolicy) SetUserMetadata(key, value string) error {
return nil
}

// SetUserMetadataStartsWith - Set how an user metadata should starts with.
// Can be retrieved through a HEAD request or an event.
func (p *PostPolicy) SetUserMetadataStartsWith(key, value string) error {
if strings.TrimSpace(key) == "" || key == "" {
return errInvalidArgument("Key is empty")
}
headerName := fmt.Sprintf("x-amz-meta-%s", key)
policyCond := policyCondition{
matchType: "starts-with",
condition: fmt.Sprintf("$%s", headerName),
value: value,
}
if err := p.addNewPolicy(policyCond); err != nil {
return err
}
p.formData[headerName] = value
return nil
}

// SetChecksum sets the checksum of the request.
func (p *PostPolicy) SetChecksum(c Checksum) {
if c.IsSet() {
Expand Down

0 comments on commit 100ddb4

Please sign in to comment.