Skip to content

Commit

Permalink
Allow to add success_action_status to policy (#549)
Browse files Browse the repository at this point in the history
  • Loading branch information
montoias authored and harshavardhana committed Nov 15, 2016
1 parent 42ea28a commit 9e35cc5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions post-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,24 @@ func (p *PostPolicy) SetContentLengthRange(min, max int64) error {
return nil
}

// SetSuccessStatusAction - Sets the status success code of the object for this policy
// based upload.
func (p *PostPolicy) SetSuccessStatusAction(status string) error {
if strings.TrimSpace(status) == "" || status == "" {
return ErrInvalidArgument("Status is empty")
}
policyCond := policyCondition{
matchType: "eq",
condition: "$success_action_status",
value: status,
}
if err := p.addNewPolicy(policyCond); err != nil {
return err
}
p.formData["success_action_status"] = status
return nil
}

// addNewPolicy - internal helper to validate adding new policies.
func (p *PostPolicy) addNewPolicy(policyCond policyCondition) error {
if policyCond.matchType == "" || policyCond.condition == "" || policyCond.value == "" {
Expand Down

0 comments on commit 9e35cc5

Please sign in to comment.