SetCondition - Sets condition for credentials, date and algorithm
(matchType, condition, value string)
| 135 | |
| 136 | // SetCondition - Sets condition for credentials, date and algorithm |
| 137 | func (p *PostPolicy) SetCondition(matchType, condition, value string) error { |
| 138 | if strings.TrimSpace(value) == "" { |
| 139 | return errInvalidArgument("No value specified for condition") |
| 140 | } |
| 141 | |
| 142 | policyCond := policyCondition{ |
| 143 | matchType: matchType, |
| 144 | condition: "$" + condition, |
| 145 | value: value, |
| 146 | } |
| 147 | if condition == "X-Amz-Credential" || condition == "X-Amz-Date" || condition == "X-Amz-Algorithm" { |
| 148 | if err := p.addNewPolicy(policyCond); err != nil { |
| 149 | return err |
| 150 | } |
| 151 | p.formData[condition] = value |
| 152 | return nil |
| 153 | } |
| 154 | return errInvalidArgument("Invalid condition in policy") |
| 155 | } |
| 156 | |
| 157 | // SetTagging - Sets tagging for the object for this policy based upload. |
| 158 | func (p *PostPolicy) SetTagging(tagging string) error { |