From 2360a332d10880fd0c9b85dfdfc456b3507d1255 Mon Sep 17 00:00:00 2001 From: Paulo Monteiro Date: Thu, 10 Nov 2016 11:07:11 +0000 Subject: [PATCH] Allow to add success_action_status to policy --- post-policy.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/post-policy.go b/post-policy.go index 2a675d770..5e716124a 100644 --- a/post-policy.go +++ b/post-policy.go @@ -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 == "" {